Node js testing

Which node js testing framework should be used in order to test the main node Js application from a completely different node testing application ?

1 Like

Are you asking what frameworks people use for testing their node apps?

I prefer a simple mocha set-up with Supertest and the Expect assertion library.

I’ve also used Karma and Enzyme for testing React components, but I’m still learning my way around those.

i understand that but i am asking that can mocha be used in one app which is a testing app made in particular and we test the main app through it .?

That is an interesting idea, making an app that can test apps.

It’s possible. But I don’t think it’s any easier than setting up testing directly in your app.

How would you set up tests? It would be impossible to set up generalized tests for every possible type of “code”. You’d probably still need *.test.js files with custom assertions.

I’d love to be proven wrong though. Imagine how many hours could be saved if there were a completely automated test “app”.

I need help am new on Backend am still managing packages with npm. Am getting an error when testing npm can you help.

nodejstutorials@1.0.1 test C:\Users\Thozamile\dev
node test.js

"name": “nodejstutorials”,
SyntaxError: Unexpected token :
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions…js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
npm ERR! Test failed. See above for more details.

Uh oh! The test failed!
Try creating a test that actually works.

I’d love to help. Is your code posted somewhere (github) so we can try to debug it? An error message on its own isn’t enough for a proper recommendation. (Looks like maybe you didn’t close your object properly, but I’m guessing without seeing actual code.)

Also, try to put your code in a code block. All it takes is ``` before and after the code and makes your code easier to read. :slight_smile:

    3 little backticks above

    // Heres's where your code goes

    3 little backticks below