# cy2

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

Latest version **4.0.9** (published 2023-12-08) · GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install cy2
pnpm add cy2
yarn add cy2
bun add cy2
```

Provides the command `cy2`.

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.0.9 |
| Published | 2023-12-08 |
| First published | 2021-03-27 |
| Weekly downloads | 0 |
| License | GPL-3.0-or-later |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14.17.0 |
| Dependencies | 12 |
| Unpacked size | 155.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 33 |
| Author | Andrew Goldis |
| Maintainers | agoldis, currents.npm |
| Keywords | cypress, sorry-cypress, cypress dashboard, cypress ci, cypress parallel, currents |

## Links

- npm: https://www.npmjs.com/package/cy2
- Repository: https://github.com/sorry-cypress/cy2
- Homepage: https://github.com/sorry-cypress/cy2#readme
- Issues: https://github.com/sorry-cypress/cy2/issues
- npm.io page: https://npm.io/package/cy2

## Dependencies (12)

- [tmp](https://npm.io/package/tmp.md) ^0.2.1
- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [fp-ts](https://npm.io/package/fp-ts.md) ^2.13.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [micromatch](https://npm.io/package/micromatch.md) ^4.0.5
- [eventemitter3](https://npm.io/package/eventemitter3.md) ^4.0.0
- [patch-package](https://npm.io/package/patch-package.md) ^6.5.1
- [requires-port](https://npm.io/package/requires-port.md) ^1.0.0
- [http-terminator](https://npm.io/package/http-terminator.md) ^3.2.0
- [follow-redirects](https://npm.io/package/follow-redirects.md) ^1.0.0
- [https-proxy-agent](https://npm.io/package/https-proxy-agent.md) ^5.0.1
- [source-map-support](https://npm.io/package/source-map-support.md) ^0.5.21

## Alternatives

- [@snazzah/davey](https://npm.io/package/@snazzah/davey.md) — 1.5M weekly downloads
- [@vendure/testing](https://npm.io/package/@vendure/testing.md) — 8.3K weekly downloads
- [vue-simple-context-menu](https://npm.io/package/vue-simple-context-menu.md) — 6.6K weekly downloads
- [cypress-webpack-preprocessor-v5](https://npm.io/package/cypress-webpack-preprocessor-v5.md) — 2.1K weekly downloads
- [@backstage/plugin-catalog-backend-module-puppetdb](https://npm.io/package/@backstage/plugin-catalog-backend-module-puppetdb.md) — 1.3K weekly downloads

## Recent versions

- 4.0.9 (latest) — 2023-12-08
- 4.0.7-beta.2 (beta) — 2023-03-10
- 4.0.5-alpha.1 (alpha) — 2023-01-16
- 4.0.8 — 2023-12-08
- 4.0.7 — 2023-12-08
- 4.0.7-beta.1 — 2023-02-17
- 4.0.7-beta.0 — 2023-02-02
- 4.0.6 — 2023-01-18
- 4.0.5-alpha.0 — 2023-01-15
- 4.0.5 — 2023-01-11
- 4.0.4-alpha.0 — 2023-01-10
- 4.0.4 — 2023-01-10
- 4.0.3 — 2023-01-09
- 4.0.2 — 2023-01-09
- 4.0.1 — 2023-01-09
- … 56 more at https://npm.io/package/cy2/versions

## README

# cy2

Integrate Cypress with alternative cloud services like Sorry Cypress or Currents

---

**[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.

**[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.

---

<p align="center">
  <img width="830" alt="banner dark" src="https://user-images.githubusercontent.com/1637928/147379205-2fe4fb9d-49e6-4a2b-917b-2a28973d2a3a.png">
</p>

![npm downloads](https://img.shields.io/npm/dw/cy2?style=flat)

`cy2` integrates [cypress](https://www.npmjs.com/package/cypress) with alternative orchestration services like Sorry Cypress or Currents.

---

**Dec 2023 Update**

If you are seeing `Error: certificate has expired`, please upgrade to version 4.0.8+.

**March 2023 Update**

⭐️ Cypress 12.6.0+ users, please use https://github.com/currents-dev/cypress-cloud if you are seeing `Cypress does not support recording test results to this third party service` error ⭐️

---

[Changelog](./CHANGELOG.md) | [License GPL-3.0+](./LICENSE)

## Install

```sh
npm install cy2
```

## CLI Usage

Set the environment variable `CYPRESS_API_URL` and run `cy2`. The command passes down all the CLI flags to cypress runner as-is.

```sh
# use `http://localhost:1234` as orchestration cloud service
CYPRESS_API_URL="http://localhost:1234/" cy2 run --parallel --record --key somekey --ci-build-id hello-cypress
```

Example usage with [sorry-cypress](https://sorry-cypress.dev). The URL should point to `director` service.

```sh
CYPRESS_API_URL="https://sorry-cypress-demo-director.herokuapp.com" cy2 run  --parallel --record --key somekey --ci-build-id hello-cypress
```

## API

### `run`

Run Cypress via its [Module API](https://docs.cypress.io/guides/guides/module-api)

```ts
run(apiUrl: string, config: CypressCommandLine.CypressRunOptions): Promise<CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult>
```

Example:

```ts
import { run } from 'cy2';

const results = await run('https://sorry-cypress.company.net', {
  reporter: 'junit',
  browser: 'chrome',
  config: {
    baseUrl: 'http://localhost:8080',
    video: true,
  },
});
```

### `spawn`

Spawn Cypress as a child process and inherit all the flags and environment variables. It invokes `process.exit` with the child process' exit code.

```ts
spawn(apiUrl: string): Promise<void>
```

Example:

```ts
import { spawn } from 'cy2';

await spawn(process.env.CYPRESS_API_URL);
```

## Breaking Changes

### Version 4

- `patch` method was deprecated. Use `run` instead.

### Version 3

- Starting version 3+, the API methods `run` and `patch` rely on `process.env.CYPRESS_API_URL` instead of accepting an argument. That's because of a new patching method that doesn't permanently change cypress configuration after invoking `cy2`.

### `patch` [deprecated in 4+]

> Deprecated due to the changes in cypress introduced in version 12+.

Change cypress configuration without running it.

```ts
patch(cypressPackageEntryPath: string) => Promise<void>
```

⚠️ Make sure to set `process.env.CYPRESS_API_URL` before invoking `patch`

Example:

```ts
import { patch } from 'cy2';
import cypress from 'cypress';

process.env.CYPRESS_API_URL = 'https://dashboard.service.url';

async function main() {
  // optional - provide cypress package main entry point location
  await patch(require.resolve('cypress'));

  cypress
    .run({
      // the path is relative to the current working directory
      spec: './cypress/e2e/examples/actions.cy.js',
    })
    .then((results) => {
      console.log(results);
    })
    .catch((err) => {
      console.error(err);
    });
}
main().catch((error) => {
  console.error(error);
  process.exit(1);
});
```

---
_Source: https://npm.io/package/cy2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
