description |
---|
Running Cypress tests with NX |
{% hint style="info" %} The instructions below apply to @currents/nx 2.0.0+ {% endhint %}
Nx is a build system with monorepo support and powerful integrations. You can run cypress tests on Currents using @currents/nx
plugin and defining a few configuration options.
See https://github.com/currents-dev/currents-nx for an example installation and configuration
First, install @currents/nx
npm package.
npm i --save-dev @currents/nx cypress-cloud
# install cypress if needed
npm i --save-dev cypress
Add currents
target to your project configuration.
{
"targets": {
"currents": {
"executor": "@currents/nx:currents",
"options": {
"record": true,
"parallel": true,
"cypressConfig": "apps/app-e2e/cypres.config.ts",
"devServerTarget": "my-react-app:serve",
"testingType": "e2e"
}
}
}
}
Create a new configuration file: currents.config.js
next to cypress.config.{jt}s
// currents.config.js
module.exports = {
// Set the `projected` and the record key obtained from https://app.currents.dev or your self-hosted instance of Sorry Cypress
projectId: 'IfERfK',
// Sorry Cypress users - set the director service URL
cloudServiceUrl: 'https://cy.currents.dev',
};
Add cypress-cloud/plugin
to cypress.config.{js|ts|mjs}
import { nxE2EPreset } from '@nrwl/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';
import cloudPlugin from 'cypress-cloud/plugin';
export default defineConfig({
e2e: {
...nxE2EPreset(__dirname, {
bundler: 'vite',
}),
specPattern: './src/**/*.cy.ts',
setupNodeEvents(on, config) {
return cloudPlugin(on, config);
},
},
});
npx nx run web-e2e:currents --key <recordKey> --ci-build-id hello-currents-nx
- Update your
currents.config.js
file withprojectId
obtained at https://app.currents.dev - Use the record key obtained at https://app.currents.dev
- Learn more about ci-build-id.md