examples icon indicating copy to clipboard operation
examples copied to clipboard

can't run test.js

Open CyanGlory opened this issue 9 years ago • 9 comments

I'v installed the dependence, but , I can't run the test.js file like this:

node .\base-auth\test.js

It shows ReferenceError: describe is not defined. can they be runing successfully in your computer?

I use vscode 1.17.1 Os: windows node is the latest version 8.6.0

CyanGlory avatar Oct 11 '17 11:10 CyanGlory

npm run test also failed, this is the error log:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'test' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle [email protected]~pretest: [email protected]
6 info lifecycle [email protected]~test: [email protected]
7 verbose lifecycle [email protected]~test: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~test: PATH: D:\nvm\v8.6.0\node_modules\npm\bin\node-gyp-bin;F:\demo\examples\node_modules\.bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;D:\Git\cmd;C:\Program Files\MongoDB\Server\3.4\bin\;C:\Users\Administrator.TUVRNIXJMBJSWX6\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Users\Administrator.TUVRNIXJMBJSWX6\AppData\Local\Microsoft\WindowsApps;D:\编辑器VsCode\Microsoft VS Code\bin;D:\nvm;C:\Program Files\nodejs
9 verbose lifecycle [email protected]~test: CWD: F:\demo\examples
10 silly lifecycle [email protected]~test: Args: [ '/d /s /c', 'make test' ]
11 silly lifecycle [email protected]~test: Returned: code: 1  signal: null
12 info lifecycle [email protected]~test: Failed to exec test script
13 verbose stack Error: [email protected] test: `make test`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (D:\nvm\v8.6.0\node_modules\npm\lib\utils\lifecycle.js:289:16)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at EventEmitter.emit (events.js:213:7)
13 verbose stack     at ChildProcess.<anonymous> (D:\nvm\v8.6.0\node_modules\npm\lib\utils\spawn.js:40:14)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at ChildProcess.emit (events.js:213:7)
13 verbose stack     at maybeClose (internal/child_process.js:927:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
14 verbose pkgid [email protected]
15 verbose cwd F:\demo\examples
16 verbose Windows_NT 10.0.15063
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
18 verbose node v8.6.0
19 verbose npm  v5.3.0
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] test: `make test`
22 error Exit status 1
23 error Failed at the [email protected] test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

CyanGlory avatar Oct 11 '17 11:10 CyanGlory

test.js是个测试脚本,你先安装Mocha,然后运行Mocha 404/test.js @CyanGlory

Isabelle-wfj avatar Dec 01 '17 09:12 Isabelle-wfj

Once you've done an npm install, run npm test.

If you'd like to specifically target the tests in base-auth/test.js, change the highest-level describe to describe.only, like so:

describe.only('Koa Basic Auth', function() { ...

npm test actually runs a Makefile in the background, not just simply running the test file with the Node command line.

reeceaw avatar Jan 18 '18 16:01 reeceaw

hi @CyanGlory unfortunately, the current "npm test" command is based on a makefile to manage all the scripts to execute. "make" is not natively available on windows, you need to install it (https://cognitivewaves.wordpress.com/makefiles-windows/)

kevinrambaud avatar Jan 22 '18 22:01 kevinrambaud

I was curious, why use make and not just npm?

joeyguerra avatar Mar 15 '18 18:03 joeyguerra

I think that this is what tj used to use to manage scripting orchestration in his projects.

kevinrambaud avatar Mar 15 '18 23:03 kevinrambaud

I was curious, why use make and not just npm?

Carrie999 avatar Nov 08 '18 09:11 Carrie999

this is old, converting to npm run is welcomed

jonathanong avatar Apr 28 '20 04:04 jonathanong

I submitted a PR to use npm run instead.

joeyguerra avatar Apr 28 '20 17:04 joeyguerra