Hi nx i created a new n…

1 minute read

Hi nx, i created a new nx project (npx create-nx-workspace, v8.11.0) with two different component libraries (ng g lib x.ng g component y) To test the components of the libraries i wanted to use the new storybook-configuration (ng generate storybook-configuration x). Every test is working when running in isolation (ng e2e x) unfortunately it fails when running all e2e tests after another using ng e2e. the first is passing but all subsequent tests are failing for the same reason (CypressError: Timed out retrying: Expected to find element: '...', but never found it. ) After some debugging i found out that all storybook processes only contains the stories of the first library. When having library a with component a and library b with component b the storybook of library b contains the story for component a which leads to a failing test because component b cannot be found in the storybook process.

Responses:

Hey Patrick, think you might be a bit confused about the CLI commands, ng e2e doesn’t run ALL it runs just the e2e tests for whatever the default project is (if this is a new workspace it would be the app that was created with it. Of you want to run all/affected you can use the yarn affected:e2e script that is in the package json that nx created.

That being said I’m not sure why running it via default would fail when running it directly is fine

Hey Jay, thanks for the quick response. the affected:e2e does the job right. running all e2e tests (both new created libraries) with the correct storybook instances. when the normal ng e2e is only running the main project, is there a way to run all e2e tests in a project? would like to use it before performing a production deployment to make sure everything is working as expected

Yarn affected:e2e –all

The affected commands have a slew of options that are detailed in the nx.dev docs

Thanks :+1:

Updated: