1
votes

I'm using Stencil.js to create a web component library and I'm heavily relying on E2E tests. As they're rather slow it becomes more and more cumbersome to run the entire test suite (using the Stencil.js CLI) while developing new components.

However, I'm not able to run single tests in my IDE (IntelliJ IDEA) or via command line. It works perfectly fine for unit tests though.

My Jest config looks like this:

module.exports = {
  "roots": [
    "<rootDir>/src"
  ],
  "preset": "@stencil/core/testing"
}

When I try to run tests in a single file (jest --config jest.config.js --testPathPattern src/components/button/button.e2e.ts$)

it fails, because

newE2EPage() is only available from E2E tests, and ran with the --e2e cmd line flag.

newE2EPage() comes with Stencil.js and I don't know what Stencil.js's CLI does in the background. Furthermore, I cloned the Stencil.js repository, just to see if it is working with their E2E tests (https://github.com/ionic-team/stencil/tree/master/test/end-to-end) but it doesn't work either.

Any idea how I can configure Jest so that it's able to run Stencil.js-E2E tests from the command line?

3

3 Answers

1
votes

The --e2e flag is used for the npm script in the package.json. To start e2e tests, you can add this in your package.json:

"scripts": {
  "test:e2e": "stencil test --e2e"
}

And run npm run test:e2e. For a specific file, you add it at the end like this:

npm run test:e2e src/components/button/button.e2e.ts

For more info, see the StencilJS doc: https://stenciljs.com/docs/end-to-end-testing

0
votes

i have the same problem. IntelliJ and 'Run' single 'it' didnt work.

newE2EPage() is only available from E2E tests, and ran with the --e2e cmd line flag.

when i run 'npm run test' everything will work fine. the difference is that npm run stencil before and only jest dont work.

here is the stencil jest dir https://github.com/ionic-team/stencil/tree/master/src/testing/jest aswell a config.

i found in here https://stenciljs.com/docs/testing-overview a VS-CODE run jest code but no Intellij setup.

im on the run to get the path of the current file to run stencil via npm and the path the e2e file. but i cant find the correct variable for the run config.

i hope we got this solved soon.

cheers

0
votes

I am not a VS Code user, but in contrast to IntelliJ there is a launch.json for VSC to run single tests: https://github.com/ionic-team/stencil-site/pull/480