# cypress-v10-preserve-cookie

> Cypress.Cookies.preserveOnce for Cypress v10

Latest version **1.2.1** (published 2022-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install cypress-v10-preserve-cookie
pnpm add cypress-v10-preserve-cookie
yarn add cypress-v10-preserve-cookie
bun add cypress-v10-preserve-cookie
```

## 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 | 1.2.1 |
| Published | 2022-09-23 |
| First published | 2022-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Gleb Bahmutov |
| Maintainers | bahmutov |
| Keywords | cypress-plugin, cypress-command |

## Links

- npm: https://www.npmjs.com/package/cypress-v10-preserve-cookie
- Repository: https://github.com/bahmutov/cypress-v10-preserve-cookie
- Homepage: https://github.com/bahmutov/cypress-v10-preserve-cookie#readme
- Issues: https://github.com/bahmutov/cypress-v10-preserve-cookie/issues
- npm.io page: https://npm.io/package/cypress-v10-preserve-cookie

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ^4.3.4

## 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

- 1.2.1 (latest) — 2022-09-23
- 1.2.0 — 2022-09-14
- 1.1.1 — 2022-09-07
- 1.1.0 — 2022-09-07
- 1.0.0 — 2022-09-07

## README

# cypress-v10-preserve-cookie ![cypress version](https://img.shields.io/badge/cypress-10.8.0-brightgreen) [![ci](https://github.com/bahmutov/cypress-v10-preserve-cookie/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bahmutov/cypress-v10-preserve-cookie/actions/workflows/ci.yml)

> Cypress.Cookies.preserveOnce for Cypress v10

- 📺 [How To Preserve Cookie Once In Cypress v10](https://youtu.be/b8aoVh6IdCg)

## Install

```shell
# if using NPM
$ npm i -D cypress-v10-preserve-cookie
# if using Yarn
$ yarn add -D cypress-v10-preserve-cookie
```

Import this module from your spec file or from your support file

```js
import 'cypress-v10-preserve-cookie'
```

This module adds a custom command `cy.preserveCookieOnce`

## Use

### Single cookie

```js
// login sets the cookie like "connect.session" for example
before(loginSomehow)

beforeEach(() => {
  // equivalent to cy.preserveCookieOnce('connect.session')
  cy.preserveCookieOnce('connect.session')
})

it('is logged in', () => {
  ...
})

it('is still logged in', () => {
  ...
})
```

### Multiple cookies

You can pass multiple cookie names

```js
cy.preserveCookieOnce(
  'connect.session',
  'refresh_token',
  'access_token',
)
// equivalent to
cy.preserveCookieOnce('connect.session')
cy.preserveCookieOnce('refresh_token')
cy.preserveCookieOnce('access_token')
```

## Types

Included in [src/index.d.ts](./src/index.d.ts)

## Debugging

This module uses [debug](https://github.com/debug-js/debug#readme) module to output verbose browser console messages when needed. To turn the logging on, open the browser's DevTools console and set the local storage entry:

```js
localStorage.debug = 'cypress-v10-preserve-cookie'
```

If you re-run the tests, you should see the messages appear in the console.

![Show debug messages](./images/debug-cookie.png)

## Examples

- [bahmutov/cypress-v10-preserve-cookie-example](https://github.com/bahmutov/cypress-v10-preserve-cookie-example)

## See also

If you need more control over storing/restoring cookies/users/any other data, check out my plugin [cypress-data-session](https://github.com/bahmutov/cypress-data-session).

## Small print

Author: Gleb Bahmutov &lt;gleb.bahmutov@gmail.com&gt; &copy; 2022

- [@bahmutov](https://twitter.com/bahmutov)
- [glebbahmutov.com](https://glebbahmutov.com)
- [blog](https://glebbahmutov.com/blog)
- [videos](https://www.youtube.com/glebbahmutov)
- [presentations](https://slides.com/bahmutov)
- [cypress.tips](https://cypress.tips)
- [Cypress Tips & Tricks Newsletter](https://cypresstips.substack.com/)
- [my Cypress courses](https://cypress.tips/courses)

License: MIT - do anything with the code, but don't blame me if it does not work.

Support: if you find any problems with this module, email / tweet /
[open issue](https://github.com/bahmutov/cypress-v10-preserve-cookie/issues) on Github

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