koajs / examples

Example Koa apps
4.52k stars 744 forks source link

can't run test.js #113

Closed CyanGlory closed 4 years ago

CyanGlory commented 6 years ago

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 commented 6 years ago

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 npm@5.3.0
3 info using node@v8.6.0
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle koa-examples@0.0.1~pretest: koa-examples@0.0.1
6 info lifecycle koa-examples@0.0.1~test: koa-examples@0.0.1
7 verbose lifecycle koa-examples@0.0.1~test: unsafe-perm in lifecycle true
8 verbose lifecycle koa-examples@0.0.1~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 koa-examples@0.0.1~test: CWD: F:\demo\examples
10 silly lifecycle koa-examples@0.0.1~test: Args: [ '/d /s /c', 'make test' ]
11 silly lifecycle koa-examples@0.0.1~test: Returned: code: 1  signal: null
12 info lifecycle koa-examples@0.0.1~test: Failed to exec test script
13 verbose stack Error: koa-examples@0.0.1 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 koa-examples@0.0.1
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 koa-examples@0.0.1 test: `make test`
22 error Exit status 1
23 error Failed at the koa-examples@0.0.1 test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Isabelle-wfj commented 6 years ago

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

reeceaw commented 6 years ago

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.

kevinrambaud commented 6 years ago

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/)

joeyguerra commented 6 years ago

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

kevinrambaud commented 6 years ago

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

Carrie999 commented 5 years ago

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

jonathanong commented 4 years ago

this is old, converting to npm run is welcomed

joeyguerra commented 4 years ago

I submitted a PR to use npm run instead.