Skip to content

Commit

Permalink
docs(testing): add example of extending CT preset (#16641)
Browse files Browse the repository at this point in the history
(cherry picked from commit a3875cc)
  • Loading branch information
barbados-clemens authored and FrozenPandaz committed Apr 28, 2023
1 parent 81fb58b commit 39ae390
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ The build target option can be changed later via updating the `devServerTarget`
When using component testing make sure to set `skipServe: true` in the component test target options, otherwise `@nx/cypress` will attempt to run the build first which can slow down your component tests. `skipServe: true` is automatically set when using the `cypress-component-configuration` generator.
{% /callout %}

## Configuration

When using the `cypress-component-configuration` generator, a helper function is used in the `cypress.config.ts` to setup the ideal settings for your project.

If you need to add additional configuration properties, you can spread the returned object from the helper function.

```ts {%filename="cypress.config.ts"}
export default defineConfig({
component: {
...nxComponentTestingPreset(__filename),
// add your own config here
},
});
```

## Testing Projects

Run `nx component-test your-lib` to execute the component tests with Cypress.
Expand Down
15 changes: 15 additions & 0 deletions docs/shared/packages/cypress/cypress-component-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ The build target option can be changed later via updating the `devServerTarget`
When using component testing make sure to set `skipServe: true` in the component test target options, otherwise `@nx/cypress` will attempt to run the build first which can slow down your component tests. `skipServe: true` is automatically set when using the `cypress-component-configuration` generator.
{% /callout %}

## Configuration

When using the `cypress-component-configuration` generator, a helper function is used in the `cypress.config.ts` to setup the ideal settings for your project.

If you need to add additional configuration properties, you can spread the returned object from the helper function.

```ts {%filename="cypress.config.ts"}
export default defineConfig({
component: {
...nxComponentTestingPreset(__filename),
// add your own config here
},
});
```

## Testing Projects

Run `nx component-test your-lib` to execute the component tests with Cypress.
Expand Down

0 comments on commit 39ae390

Please sign in to comment.