# jest-environment-nightwatch

> Nightwatch.js environment for Jest

Latest version **0.2.2** (published 2022-02-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install jest-environment-nightwatch
pnpm add jest-environment-nightwatch
yarn add jest-environment-nightwatch
bun add jest-environment-nightwatch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2022-02-07 |
| First published | 2022-01-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Andrei Rusu |
| Maintainers | beatfactor |
| Keywords | nightwatch.js, jest, jest-environment |

## Links

- npm: https://www.npmjs.com/package/jest-environment-nightwatch
- npm.io page: https://npm.io/package/jest-environment-nightwatch

## Dependencies (1)

- [jest-environment-node](https://npm.io/package/jest-environment-node.md) ^27.4.6

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 0.2.2 (latest) — 2022-02-07
- 0.2.1 — 2022-01-26
- 0.2.0 — 2022-01-26
- 0.1.1 — 2022-01-26
- 0.1.0 — 2022-01-26

## README

# jest-environment-nightwatch
**[Nightwatch 2](https://v2.nightwatchjs.org)** environment for Jest. Nightwatch.js is an integrated test framework for performing automated end-to-end testing on web applications and websites, across all major browsers.

[![Build Status][build-badge]][build]
[![version][version-badge]][package]
[![Discord][discord-badge]][discord]
[![MIT License][license-badge]][license]

```
npm install jest-environment-nightwatch
```

## Usage:
Update your [Jest configuration](https://jestjs.io/docs/configuration):

```js
{
  testEnvironment: 'jest-environment-nightwatch',
  testEnvironmentOptions: {
    // Nightwatch related options
    headless: true,
    browserName: 'chrome',
    baseUrl: '',
    verbose: false,  
    output: true,
    env: null, 
    parallel: false,
    devtools: false,
    debug: false,
    autoStartSession: true,
    persistGlobals: true,
    configFile: './nightwatch.conf.js',
    globals: {}, 
    webdriver: {},
    timeout: null,
    enableGlobalApis: false,
    alwaysAsync: true,
    desiredCapabilities: {},
    async setup(browser) {},
    async teardown(browser) {},
  }
}
```

## Nightwatch options

| Name| Type | Description | Default |
|:--- | :--- | :--- | :---: |
| **`headless`**| Boolean  | Run Nightwatch in headless mode (available in Firefox, Chrome, Edge) | `true` | 
| **`browserName`** | String  | Browser name to use; available options are: `chrome`, `firefox`, `edge`, `safari` | none | 
| **`baseUrl`** | String  | The base url to use for the when using `.navigateTo()` with relative urls. When doing component testing it needs to be set to the url running the Vite dev server. | `http://localhost:3000` | 
| **`verbose`** | Boolean  | Enable complete Nightwatch http logs. | `false` |
| **`output`** | Boolean  | Show Nightwatch output. | `true` |
| **`env`** | String  | Nightwatch test environment to use, from `nightwatch.conf.js`. Learn more about test environments in the [Nightwatch docs](https://v2.nightwatchjs.org/guide/using-nightwatch/concepts.html#defining-test-environments). | none |
| **`parallel`** | Boolean  | Set this to true when running tests in parallel | `false` |
| **`devtools`** | Boolean  | Chrome only: automatically open the chrome devtools | `false` |
| **`debug`** | Boolean  | Component testing only: pause the test execution after rendering the component | `false` |
| **`autoStartSession`** | Boolean  | Start the Nightwatch session automatically. If this is disabled, you'll need to call `jestNightwatch.launchBrowser()` in your tests. | `true` |
| **`persistGlobals`** | Boolean  | Persist the same globals object between runs or have a (deep) copy of it per each test. Learn more about test globals in the [Nightwatch docs](https://v2.nightwatchjs.org/guide/using-nightwatch/concepts.html#using-test-globals).| `true` |
| **`configFile`** | String  | The Nightwatch config file to use. A config file will be auto-generated by default, but this allows you to change that. Learn more about the Nightwatch config in the [Nightwatch docs](https://v2.nightwatchjs.org/guide/configuration/overview.html). | `./nightwatch.conf.js` |
| **`globals`** | Object  | A list of globals to be used in Nightwatch. Globals are available on `browser.globals`. Learn more about the Nightwatch test globals in the [Nightwatch docs](https://v2.nightwatchjs.org/guide/using-nightwatch/external-globals.html). | none |
| **`webdriver`** | Object  | A list of Webdriver related settings to configure the Nightwatch Webdriver service. Learn more about the Nightwatch webdriver settings in the [Nightwatch docs](https://v2.nightwatchjs.org/guide/configuration/settings.html#webdriver-settings). | none |
| **`timeout`** | Number  | Set the global timeout for assertion retries before an assertion fails.  | `5000` |
| **`enableGlobalApis`** | Boolean  | The Nightwatch global APIs ([element()](https://v2.nightwatchjs.org/api/element/), [expect()](https://v2.nightwatchjs.org/api/expect/)) are disable by default. | `false` |
| **`desiredCapabilities`** | Object  | Define custom Selenium capabilities for the current session. Learn more about the specific browser driver that it is being used on the [Nightwatch docs](https://v2.nightwatchjs.org/guide/browser-drivers-setup/). | none |
| **`setup()`** | Function  | Additional setup hook to be executed after Nightwatch has been started. | none |
| **`teardown()`** | Function  | Additional teardown hook to be executed with the Nightwatch api object. | none |

## API

### `global.browser`

The Nightwatch [browser API](https://v2.nightwatchjs.org/api/#the-browser-object) object. Unavailable when `autoStartSession` is off.


### `global.jestNightwatch`

The Jest environment used the Nightwatch [programmatic API](https://v2.nightwatchjs.org/api/programmatic/) to create the Nightwatch instance and export the browser API. 

Available properties/methods:
- `.element(<locator>)` - use the Nightwatch [.element() API](https://v2.nightwatchjs.org/api/element/) to locate elements in the page;
- `.updateCapabilities({ capabilities })` - used when `autoStartSession` is off in order to update the capabilities at run-time;
- `.launchBrowser()` - used when `autoStartSession` is off in order to start the session and open the browser;
- `.settings` - the Nightwatch settings object;
- `.nightwatch_client` - the Nightwatch (internal) instance.


## License
MIT

[build-badge]: https://github.com/nightwatchjs/jest-environment-nightwatch/actions/workflows/node.js.yml/badge.svg?branch=main
[build]: https://github.com/nightwatchjs/jest-environment-nightwatch/actions/workflows/node.js.yml
[version-badge]: https://img.shields.io/npm/v/jest-environment-nightwatch.svg?style=flat-square
[package]: https://www.npmjs.com/package/jest-environment-nightwatch
[license-badge]: https://img.shields.io/npm/l/jest-environment-nightwatch.svg?style=flat-square
[license]: https://github.com/nightwatchjs/jest-environment-nightwatch/blob/main/LICENSE
[discord-badge]: https://img.shields.io/discord/618399631038218240.svg?color=7389D8&labelColor=6A7EC2&logo=discord&logoColor=ffffff&style=flat-square
[discord]: https://discord.gg/SN8Da2X

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