forked from currents-dev/cypress-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
28,277 additions
and
7,101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
} | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"[xml]": { | ||
"editor.defaultFormatter": "DotJoshJohnson.xml" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,120 @@ | ||
### Cypress Cloud 2.0 | ||
# Cypress Cloud (@currents/cypress) | ||
|
||
This is an experimental package that integrates cypress with Currents (and sorry cypress). It implements the orchestration protocol and results reporting, mimicking the internal cypress implementation. It runs cypress in "local" mode, explicitly providing the specific spec file to run each time. | ||
Integrate Cypress with alternative cloud services like Currents or Sorry Cypress. | ||
|
||
The flow is: | ||
--- | ||
|
||
- Get resolved cypress configuration | ||
- Run cypress as a child process with non-existing spec file | ||
- Dump the resolved config to a temp file (using the cypress plugin) | ||
- Collect resolved configuration from a temp file | ||
- Discover spec files that need to run using the config file | ||
- Create a new run in dashboard, start running spec files, invoking cypress from scratch for each spec file | ||
- Upload results | ||
**[Currents.dev](https://currents.dev/?utm_source=cy2)** - is a hosted cloud service used to run millions of Cypress tests without breaking the bank. This is an enhanced version of Sorry Cypress with better security, performance, analytics, integrations and support. | ||
|
||
## Setup | ||
**[Sorry Cypress](https://sorry-cypress.dev/?utm_source=cy2)** - is an open-source, free alternative to Cypress Cloud that unlocks unlimited parallelization, test recordings, and integration with GitHub, Slack and more. | ||
|
||
See an example setup in `examples/nextjs` directory: | ||
--- | ||
|
||
- note the "plugin" in `examples/nextjs/cypress.config.ts` | ||
- projectId is defined in `currents.config.js` | ||
[Changelog](./CHANGELOG.md) | [License](./LICENSE) | ||
|
||
To run an example, make sure that currents is running locally and then: | ||
## Setup | ||
|
||
``` | ||
cd packages/cypress-cloud | ||
nvm use # OR nvm install | ||
yarn watch | ||
Install the package | ||
|
||
```sh | ||
npm install @currents/cypress | ||
``` | ||
|
||
... then in another terminal | ||
Create a new configuration file: `currents.config.js` in the project’s root and set the `projectId` and the record key obtained from [Currents](https://app.currents.dev) or your self-hosted instance of Sorry Cypress: | ||
|
||
```js | ||
module.exports = { | ||
projectId: "Ij0RfK", | ||
recordKey: "xxx", | ||
}; | ||
``` | ||
cd examples/nextjs | ||
cp .env.example .env | ||
export CURRENTS_RECORD_KEY=YOUR_CURRENTS_RECORD_KEY | ||
|
||
Add `@currents/cypress/plugin` plugin to `cypress.config.{js|ts|mjs}` | ||
|
||
```js | ||
// cypress.config.js | ||
const { defineConfig } = require("cypress"); | ||
const { cloudPlugin } = require("@currents/cypress/plugin"); | ||
module.exports = defineConfig({ | ||
e2e: { | ||
setupNodeEvents(on, config) { | ||
cloudPlugin(on, config); | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
Once you created new `.env` file please fill in all env variales from example file by using currents dashboard. | ||
## Usage | ||
|
||
Use the command bellow to run currents runner: | ||
Obtain the record key from https://app.currents.dev (or use any value for Sorry Cypress) | ||
|
||
``` | ||
yarn cypress | ||
```sh | ||
npx cypress-cloud --parallel --record --key <your_key> --ci-build-id hello-cypress-cloud | ||
``` | ||
|
||
## Testing | ||
See all the available options `npx cypress-cloud --help` | ||
|
||
``` | ||
yarn test | ||
``` | ||
## Example | ||
|
||
Please note, we use `esbuild` for building and `swc` for testing. In addition, jest has built-in module aliases, but eslint does not. Beware of importing aliases in non-testing code. | ||
See an example in [examples/webapp](./example/webapp) directory | ||
|
||
## What's inside? | ||
## Configuration | ||
|
||
This turborepo uses [Yarn](https://yarnpkg.com/) as a package manager. It includes the following packages/apps: | ||
```js | ||
// currents.config.js | ||
module.exports = { | ||
projectId: "Ij0RfK", | ||
recordKey: "the record key from currents.dev", | ||
}; | ||
``` | ||
|
||
### Examples and Packages | ||
Override the default configuration values via environment variables: | ||
|
||
- `nextjs`: an example [Next.js](https://nextjs.org/) app with Currents Cypress Cloud setup | ||
- `eslint-config-custom`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`) | ||
- `CURRENTS_API_BASE_URL` - sorry-cypress users - set the URL of your director service | ||
- `CURRENTS_PROJECT_ID` - set the `projectId` | ||
- `CURRENTS_RECORD_KEY` - cloud service record key | ||
|
||
Each package/example is 100% [TypeScript](https://www.typescriptlang.org/). | ||
## API | ||
|
||
### Utilities | ||
### `run` | ||
|
||
This turborepo has some additional tools already setup for you: | ||
Run Cypress tests programmatically | ||
|
||
- [TypeScript](https://www.typescriptlang.org/) for static type checking | ||
- [ESLint](https://eslint.org/) for code linting | ||
- [Prettier](https://prettier.io) for code formatting | ||
```ts | ||
run(params: CurrentsRunParameters): Promise<CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult> | ||
``` | ||
|
||
### Build | ||
- `params` - [CurrentsRunParameters](./packages/cypress-cloud/types.ts#L123) list of params compatible with Cypress [Module API](https://docs.cypress.io/guides/guides/module-api) | ||
|
||
To build all apps and packages, run the following command: | ||
- returns results as a [CypressRunResult](https://github.com/cypress-io/cypress/blob/19e091d0bc2d1f4e6a6e62d2f81ea6a2f60d531a/cli/types/cypress-npm-api.d.ts#L277) | ||
|
||
``` | ||
cd cypress-cloud | ||
yarn run build | ||
Example: | ||
|
||
```ts | ||
import { run } from "@currents/cypress"; | ||
|
||
const results = await run({ | ||
reporter: "junit", | ||
browser: "chrome", | ||
config: { | ||
baseUrl: "http://localhost:8080", | ||
video: true, | ||
}, | ||
}); | ||
``` | ||
|
||
### Develop | ||
## Troubleshooting | ||
|
||
To develop all apps and packages, run the following command: | ||
Enable the debug mode and run the command | ||
|
||
```sh | ||
DEBUG=currents:* npx cypress-cloud run ... | ||
``` | ||
cd cypress-cloud | ||
yarn run dev | ||
|
||
## Testing | ||
|
||
```sh | ||
yarn test | ||
``` | ||
|
||
> Please note, we use `esbuild` for building and `swc` for testing. In addition, jest has built-in module aliases, but eslint does not. Beware of importing aliases in non-testing code. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.