Skip to content

Commit

Permalink
Feat: use cypress-cloud (#18)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

- Use cypress-cloud as an integration tool
- `@nrwl/cypress` no longer required, versions - the plugin is a standalone implementation that is not dependent on `@nrwl/cypress`

* feat: standalone implementation

- `@nrwl/cypress` no longer required, versions - the plugin is a standalone implementation that is not dependent on `@nrwl/cypress`
- use the available options to configure the execution of your cypress runs

* Release 1.0.0-beta.1

* chore: resolve security warnings

* Release 1.0.0-beta.2

* feat: use cypress-cloud

* chore: remove unused files

* chore: remove deps

* feat: use cypress-cloud
  • Loading branch information
agoldis authored Apr 4, 2023
1 parent 572c047 commit 8bec6fe
Show file tree
Hide file tree
Showing 64 changed files with 25,023 additions and 12,679 deletions.
9 changes: 8 additions & 1 deletion .eslintrc → .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {}
"rules": {},
"overrides": [
{
"files": "*.json",
"parser": "jsonc-eslint-parser",
"rules": {}
}
]
}
93 changes: 93 additions & 0 deletions .github/ISSUE_TEMPLATE/1.bug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Bug report
description: Create a report to help us improve @currents/nx
labels: bug

body:
- type: checkboxes
attributes:
label: |
Before opening, please confirm:
options:
- label: I have [searched for duplicate or closed issues](https://github.com/currents-dev/currents-nx/issues) and [discussions](https://github.com/currents-dev/currents-nx/discussions).
required: true
- label: I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
required: true

- type: markdown
attributes:
value: |
## Environment
- type: textarea
attributes:
label: Environment information
description: |
Please run the following command inside your project and copy/paste the output below:
```
npx envinfo --system --binaries --browsers --npmPackages --duplicates --npmGlobalPackages
```
value: |
<details>
```
# Put output below this line
```
</details>
validations:
required: true
- type: markdown
attributes:
value: |
## Details
- type: textarea
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.
validations:
required: true

- type: textarea
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
validations:
required: true

- type: textarea
attributes:
label: Command and Setup
description: |
- The exact command or code snippet
- Your cloud provider and sorry-cypress setup details
validations:
required: true

- type: textarea
attributes:
label: Full log and debug output
description: |
Run in debug mode to provide more info - error messages and stack traces.
**Include the full log - starting from running the command till receiving an error.**
Attach a link / file for long outputs.
Linux: `DEBUG=cy2*,cypress:* cy2 run ...`
Windows: `cmd /V /C "set DEBUG=cy2*,cypress:* && cy2 run ..."`
**Be sure to remove any sensitive data.**
value: |
<details>
```
// Put your logs below this line
```
</details>
validations:
required: true
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/1.feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Feature Request
description: Request a new feature
labels: enhancement

body:
- type: textarea
attributes:
label: Description
description: |
Please describe the feature in details
validations:
required: true

- type: textarea
attributes:
label: Example usage
description: Please provide an example of how the feature will be used - code or command line
validations:
required: true
4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# [1.0.0-beta.2](https://github.com/currents-dev/currents-nx/compare/1.0.0-beta.1...1.0.0-beta.2) (2023-01-10)

# [1.0.0-beta.1](https://github.com/currents-dev/currents-nx/compare/0.2.1...1.0.0-beta.1) (2023-01-10)

### Features

- standalone implementation ([06d1ff1](https://github.com/currents-dev/currents-nx/commit/06d1ff1df3bb85fc4fd58c130aa4110529564a58))

### BREAKING CHANGES

- `@nrwl/cypress` no longer required, versions - the plugin is a standalone implementation that is not dependent on `@nrwl/cypress`

- use the available options to configure the execution of your cypress runs

- use cy2 3.4.1 for cypress 12 (a46f56f)

* feat: cypress 12+ (1a9ca2b)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Currents.dev
Copyright (c) 2021 Currents Software Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
104 changes: 76 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,101 @@
# @currents/nx
# Debug, troubleshoot and record Cypress CI tests in Cloud

[NX](https://nx.dev/) plugin for running cypress tests on Currents.dev
[NX](https://nx.dev/) plugin for running cypress tests using [Currents](https://currents.dev) or [Sorry Cypress](https://sorry-cypress.dev).

Integrate Cypress with alternative cloud services like Currents or Sorry Cypress.

The plugin is designed for CI environments and runs Cypress in headless mode. Please use `@nrwl/cypress` for running cypress in interactive mode.

## Example

See [./apps/web-e2e](./apps/web-e2e) for an example installation:

```sh
npx nx run web-e2e:currents --key <recordKey> --ci-build-id hello-currents-nx
```

## Setup

Install `@currents/nx`

```sh
npm i --save-dev @currents/nx
npx nx g @currents/nx:init <destination_project>
```

Add `currents` target to your project configuration
Add target `currents` to your project configuration:

```js

{
// ...
"targets": {
"currents": {
"executor": "@currents/nx:currents",
"options": {
"cypressExecutor": "e2e" // target name that runs "@nrwl/cypress:cypress"
}
},
"e2e": {
"executor": "@nrwl/cypress:cypress",
"options": {
// ...
},
"configurations": {
// ...
// ...
"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"
}
}
}
}
// ...
// ...
```
Run cypress tests, using Currents.dev as a dashboard
Create a new configuration file: `currents.config.js` next to `cypress.config.{jt}s`
```js
// currents.config.js
module.exports = {
// Set the `projectId` and the record key obtained from https://app.currents.dev or your self-hosted instance of Sorry Cypress
projectId: 'Ij0RfK',
// Sorry Cypress users - set the director service URL
cloudServiceUrl: 'https://cy.currents.dev',
};
```
Add `cypress-cloud/plugin` to `cypress.config.{js|ts|mjs}`
```ts
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);
},
},
});
```
## Usage
```sh
nx run project:currents --group nx --record --key <key> --ci-build-id hello-currents-nx
npx nx run web-e2e:currents --key <recordKey> --ci-build-id hello-currents-nx
```
- The plugin requires an already installed `@nrwl/cypress` and a configured target that's running `@nrwl/cypress:cypress`
- `@currents/nx:currents` will run `@nrwl/cypress:cypress` behind the scenes
- You can set predefined options in target definition
- Update your `cypress.json` file with `projectId` obtained at https://app.currents.dev
- Use the record key obtained at https://app.currents.dev
### Example
## Configuration
Options can be configured in `project.json` when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/reference/project-configuration#targets.
See the [schema.json](./src/executors/schema.json) for the list of available options
## Migration
### Version `2.0.0`
- Using [`cypress-cloud`](https://github.com/currents-dev/cypress-cloud) as the orchestration tool
### Version `1.0.0`
See https://github.com/currents-dev/currents-nx-example for example integration
- `@nrwl/cypress` no longer required - the plugin is a standalone implementation that is not dependent on `@nrwl/cypress`. Use the available configuration options to configure the execution of cypress runs.
10 changes: 10 additions & 0 deletions apps/web-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": ["plugin:cypress/recommended", "../../.eslintrc"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
}
]
}
3 changes: 3 additions & 0 deletions apps/web-e2e/currents.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
projectId: 'Ij0RfK',
};
15 changes: 15 additions & 0 deletions apps/web-e2e/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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);
},
},
});
32 changes: 32 additions & 0 deletions apps/web-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "web-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/web-e2e/src",
"projectType": "application",
"targets": {
"currents": {
"executor": "@currents/nx:currents",
"options": {
"projectRoot": "apps/web-e2e",
"parallel": true,
"record": true,
"tag": "nx",
"devServerTarget": "web:serve:development"
},
"configurations": {
"production": {
"devServerTarget": "web:serve:production"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/web-e2e/**/*.{js,ts}"]
}
}
},
"tags": [],
"implicitDependencies": ["web"]
}
13 changes: 13 additions & 0 deletions apps/web-e2e/src/e2e/app.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getGreeting } from '../support/app.po';

describe('web', () => {
beforeEach(() => cy.visit('/'));

it('should display welcome message', () => {
// Custom command example, see `../support/commands.ts` file
cy.login('[email protected]', 'myPassword');

// Function helper example, see `../support/app.po.ts` file
getGreeting().contains('Welcome web');
});
});
4 changes: 4 additions & 0 deletions apps/web-e2e/src/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]"
}
1 change: 1 addition & 0 deletions apps/web-e2e/src/support/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const getGreeting = () => cy.get('h1');
Loading

0 comments on commit 8bec6fe

Please sign in to comment.