PatrickJS-starter icon indicating copy to clipboard operation
PatrickJS-starter copied to clipboard

Cannot `npm run test`

Open spartanPAGE opened this issue 9 years ago • 5 comments

I have no tests, yet the test command crashes.


> [email protected] test D:\projects\fortys-edu\fortys-edu-frontend
> npm run lint && karma start


> [email protected] lint D:\projects\fortys-edu\fortys-edu-frontend
> npm run tslint "src/**/*.ts"


> [email protected] tslint D:\projects\fortys-edu\fortys-edu-frontend
> tslint "src/**/*.ts"


START:

Finished in 0.008 secs / 0 secs @ 11:19:55 GMT+0200 (Środkowoeuropejski czas letni)

SUMMARY:
√ 0 tests completed

=============================== Coverage summary ===============================
Statements   : 100% ( 0/0 )
Branches     : 100% ( 0/0 )
Functions    : 100% ( 0/0 )
Lines        : 100% ( 0/0 )
================================================================================
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `npm run lint && karma start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script 'npm run lint && karma start'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular2-webpack-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run lint && karma start
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular2-webpack-starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular2-webpack-starter
npm ERR! There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Biznes\AppData\Roaming\npm-cache\_logs\2017-04-10T09_19_55_252Z-debug.log

debug.log:

0 info it worked if it ends with ok
1 verbose cli [ 'D:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\Biznes\\AppData\\Roaming\\npm\\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 silly lifecycle [email protected]~pretest: no script for pretest, continuing
7 info lifecycle [email protected]~test: [email protected]
8 verbose lifecycle [email protected]~test: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~test: PATH: C:\Users\Biznes\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;D:\projects\fortys-edu\fortys-edu-frontend\node_modules\.bin;D:\Python\Python36\Scripts\;D:\Python\Python36\;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\Ewa Wertka\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;D:\Program Files (x86)\scala\bin;D:\scala\bin;D:\scala\sbt\\bin;D:\Go\bin;D:\Program Files (x86)\Heroku\bin;D:\Program Files\erl7.2.1\bin;D:\Program Files (x86)\Elixir\bin;C:\WINDOWS\system32\config\systemprofile\.mix\escripts;C:\ProgramData\chocolatey\bin;D:\Program Files\nodejs\;C:\Program Files\Java\jdk1.8.0_102\bin;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files\MySQL\MySQL Utilities 1.6\;D:\Program Files\Git\cmd;D:\Program Files (x86)\PuTTY\;C:\ProgramData\ComposerSetup\bin;D:\HashiCorp\Vagrant\bin;C:\Program Files (x86)\Skype\Phone\;C:\Users\Biznes\AppData\Local\Programs\Python\Python36-32\Scripts\;C:\Users\Biznes\AppData\Local\Programs\Python\Python36-32\;D:\Program Files (x86)\Elm Platform\0.17\bin;C:\Users\Biznes\AppData\Local\scoop\shims;C:\Ruby22-x64\bin;C:\Program Files (x86)\Mozilla Firefox;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\Ewa Wertka\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Skype\Phone\;C:\Users\Biznes\AppData\Local\Programs\Git\cmd;D:\scala\sbt\bin;D:\Java\jdk1.8.0_73\bin;D:\Python34;D:\Python34\Scripts;C:\Users\Biznes\AppData\Local\atom\bin;D:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\Biznes\AppData\Roaming\npm;C:\Users\Biznes\AppData\Local\Microsoft\WindowsApps;D:\Program Files (x86)\eSpeak\command_line;D:\Program Files\Docker Toolbox;D:\xampp\php;D:\Program Files\chromedriver_win32;D:\Program Files\geckodriver-v0.11.1-win32;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC;D:\typesafe-activator-1.3.12\activator-dist-1.3.12\bin;D:\php7.1;C:\Users\Biznes\AppData\Roaming\Composer\vendor\bin;D:\mongo\3.4\bin
10 verbose lifecycle [email protected]~test: CWD: D:\projects\fortys-edu\fortys-edu-frontend
11 silly lifecycle [email protected]~test: Args: [ '/d /s /c', 'npm run lint && karma start' ]
12 silly lifecycle [email protected]~test: Returned: code: 1  signal: null
13 info lifecycle [email protected]~test: Failed to exec test script
14 verbose stack Error: [email protected] test: `npm run lint && karma start`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (C:\Users\Biznes\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (C:\Users\Biznes\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:852:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
15 verbose pkgid [email protected]
16 verbose cwd D:\projects\fortys-edu\fortys-edu-frontend
17 verbose Windows_NT 10.0.14393
18 verbose argv "D:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Biznes\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
19 verbose node v6.2.2
20 verbose npm  v4.4.4
21 error code ELIFECYCLE
22 error errno 1
23 error [email protected] test: `npm run lint && karma start`
23 error Exit status 1
24 error Failed at the [email protected] test script 'npm run lint && karma start'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the angular2-webpack-starter package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error     npm run lint && karma start
24 error You can get information on how to open an issue for this project with:
24 error     npm bugs angular2-webpack-starter
24 error Or if that isn't available, you can get their info via:
24 error     npm owner ls angular2-webpack-starter
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]

spartanPAGE avatar Apr 10 '17 09:04 spartanPAGE

I have exactly the same problem

fcin avatar Apr 11 '17 18:04 fcin

I was able to partially fix the problem, by adding escape characters to tslint in package.json, which now looks like this: "lint": "npm run tslint \\\"src/**/*.ts\\\"", It looks like with only one backslash the backslash gets thrown away in the console which modifies the command to look like this: npm run tslint "src/**/*.ts", and adding additional backslashes fixes it to look like this: npm run tslint \"src/**/*.ts\" in the console. Unfortunately this doesn't completely fix the problem for me, because even though the karma starts correctly and opens up a browser, it cannot find any tests. I always get: SUMMARY: √ 0 tests completed

I also tried pointing exactly to a single file with test, so I have something like this: "lint": "npm run tslint \\\"src/app/home/home.component.spec.ts\\\"",

The spec file looks like this:

describe('sign-up', () => {

    it('test1', () => {
        expect(false).toBe(false);
    });
});

But after running npm run test, I get this:

E:\???\???\???\????>npm run test

> [email protected] test E:\???\???\???\???
> npm run lint && karma start


> [email protected] lint E:\???\???\???\???
> npm run tslint \"src/app/home/home.component.spec.ts\"


> [email protected] tslint E:\???\???\???\???
> tslint "\"src/app/home/home.component.spec.ts\""


START:

[at-loader] Using [email protected] from typescript and "tsconfig.json" from E:\???\???\???\???/tsconfig.json.


[at-loader] Checking started in a separate process...

[at-loader] Ok, 0.55 sec.
Hash: 1689d1628879fb38b321
Version: webpack 2.3.1
Time: 10113ms
                Asset    Size  Chunks                    Chunk Names
config/spec-bundle.js  7.8 MB       0  [emitted]  [big]  config/spec-bundle.js

WARNING in ./~/@angular/core/@angular/core.es5.js
5870:15-36 Critical dependency: the request of a dependency is an expression

WARNING in ./~/@angular/core/@angular/core.es5.js
5886:15-102 Critical dependency: the request of a dependency is an expression

ERROR in ./src/app/home/x-large/x-large.directive.spec.ts
Module not found: Error: Can't resolve '@angular/platform-browser/src/dom/debug/by' in 'E:\???\???\???\???\src\app\home\x-large'
 @ ./src/app/home/x-large/x-large.directive.spec.ts 6:11-64
 @ ./src \.spec\.ts
 @ ./config/spec-bundle.js

ERROR in ./src/assets/img/home/background-tri.png
Module parse failed: E:\???\???\???\???\src\assets\img\home\background-tri.png Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
 @ ./~/css-loader!./src/app/home/home.component.css 6:117-168
 @ ./src/app/home/home.component.css
 @ ./src/app/home/home.component.ts
 @ ./src/app/home/home.component.spec.ts
 @ ./src \.spec\.ts
 @ ./config/spec-bundle.js
13 04 2017 18:13:13.085:WARN [reporter]: SourceMap position not found for trace: undefined
Chrome 57.0.2987 (Windows 10 0.0.0) ERROR
  Uncaught Error: Module parse failed: E:\???\???\???\???\src\assets\img\home\background-tri.png Unexpected character '�' (1:0)
  You may need an appropriate loader to handle this file type.
  (Source code omitted for this binary file)
  at config/spec-bundle.js:81850
13 04 2017 18:13:13.087:WARN [reporter]: SourceMap position not found for trace: undefined
Chrome 57.0.2987 (Windows 10 0.0.0) ERROR
  Uncaught Error: Module parse failed: E:\???\???\???\???\src\assets\img\home\background-tri.png Unexpected character '�' (1:0)
  You may need an appropriate loader to handle this file type.
  (Source code omitted for this binary file)
  at config/spec-bundle.js:81850

Finished in 0.407 secs / 0 secs @ 18:13:13 GMT+0200 (Środkowoeuropejski czas letni)

SUMMARY:
√ 0 tests completed

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "D:\\Programy\\NodeJS\\node.exe" "D:\\Programy\\NodeJS\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
npm ERR! node v6.10.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] test: `npm run lint && karma start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script 'npm run lint && karma start'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ??? package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run lint && karma start
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ???
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls ???
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     E:\???\???\???\???\npm-debug.log

E:\???\???\???\???>

fcin avatar Apr 13 '17 16:04 fcin

I've applied your changes to see this particular result:

D:\projects\fortys-edu\fortys-edu-frontend>npm test

> [email protected] test D:\projects\fortys-edu\fortys-edu-frontend
> npm run lint && karma start


> [email protected] lint D:\projects\fortys-edu\fortys-edu-frontend
> npm run tslint \"src/**/*.ts\"


> [email protected] tslint D:\projects\fortys-edu\fortys-edu-frontend
> tslint "\"src/**/*.ts\""


START:

Finished in 0.005 secs / 0 secs @ 10:34:32 GMT+0200 (Środkowoeuropejski czas letni)

SUMMARY:
√ 0 tests completed

=============================== Coverage summary ===============================
Statements   : 100% ( 0/0 )
Branches     : 100% ( 0/0 )
Functions    : 100% ( 0/0 )
Lines        : 100% ( 0/0 )
================================================================================
npm ERR! Test failed.  See above for more details.

D:\projects\fortys-edu\fortys-edu-frontend>

So i'm supposed to see above for more details, but there is nothing about errors.

Ofc. My tests aren't getting launched.

describe('example', () => {
  it('fails', () => {
    expect(true).toBe(false);
  });
});

spartanPAGE avatar Apr 14 '17 08:04 spartanPAGE

It turns out that "lint": "npm run tslint \"src/**/*.ts\"" is completely fine. I just had erors regarding image not loading. After fixing it, it completes tests correctly, but at the end throws exception:

=============================== Coverage summary ===============================
Statements   : 90.67% ( 68/75 )
Branches     : 0% ( 0/2 )
Functions    : 76% ( 19/25 )
Lines        : 88.52% ( 54/61 )
================================================================================

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "D:\\Programy\\NodeJS\\node.exe" "D:\\Programy\\NodeJS\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
npm ERR! node v6.10.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] test: `npm run lint && karma start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script 'npm run lint && karma start'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the webcam package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run lint && karma start
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs webcam
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls webcam
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     E:\Obrazki\Javascript\webcam\webcamwebpage\npm-debug.log

Regarding your question, I'm not sure if it is true, but I think that karma by default says that tests failed if there are no tests.

fcin avatar Apr 14 '17 16:04 fcin

For others: trying own spec example in /src instead of /src/app/**/* can really mess up your week.

spartanPAGE avatar Apr 14 '17 21:04 spartanPAGE