Stencil: No tests found after run test command

Created on 9 Jun 2019  路  6Comments  路  Source: ionic-team/stencil

Stencil version:

 @stencil/[email protected]

I'm submitting a:

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:

image

Expected behavior:

image

Steps to reproduce:

Run command:

npm run-script test

instead:

npm run test

Other information:

I am using extension npm for VS Code for run scripts

triage

All 6 comments

@manucorporat could you revisit this issue? I'm running into this issue with 1.3.0 as well.

Basically it appears that jest is adding the command name as a pattern.

It is very easily reproducable by renaming the test script in package.json to test:unit. I've just reproduced it by cloning a fresh stencil-component-starter. as you can see from the screenshot I'm on W10

image

Exactly the same error occurs to me: I want to start tests with script named test:unit and it failes to run. If i place the exact same test into script test it works.

runs:
"test": "stencil test --spec",

fails:
"test:unit": "stencil test --spec",

with error: _No tests found, exiting with code 1_

This should be fixed in the latest version. If it's still a problem, would you be able to create an issue with a thorough description on how to replicate this? Thanks

@adamdbradley The issue still not fixed in 1.12.5

Just rename the generated project "test" script name to something else".
Stencil logs all jest arguments here: https://github.com/ionic-team/stencil/blob/master/src/testing/jest/jest-config.ts#L16

Output:

$ yarn test:unit
yarn run v1.22.4
$ stencil test --spec
[23:13.8]  @stencil/core v1.12.5
[23:13.9]  testing spec files
[23:14.0]  jest args: test:unit --spec --max-workers=8
No tests found, exiting with code 1

As you can see the passed jest arg is test:unit (which is the task name) not test

related package.json task:

"scripts": {
    "test:unit": "stencil test --spec",
  },

Just ran into this issue. I've created a repo based on the component starter repo to reproduce this issue:
https://github.com/bjankord/stencil-component-starter/commit/408d81584d405b9e7eaf372aa30bf9efb0485b71

If you clone that repo and run yarn test:foo or yarn preversion, Jest fails to find any tests, but if you run yarn test it works perfectly.

Edit: To @petergaal91's point, it does seem like the name of the npm script is being considered as an argument passed to jest. When running yarn test:foo, I see the following:
jest args: test:foo --spec --max-workers=8

Maybe the fix is to trim that off before calling jest, not sure if thats something that can be done in the stencil CLI.

WORK AROUND
I've found that the name of the npm script being included as an arg to jest only happens when using yarn. If I run npm run test:foo or npm run preversion those execute jest correctly.

@bjankord yarn requires you to use the run command (ie: yarn run test:foo), without run it won't work.

Was this page helpful?
0 / 5 - 0 ratings