@percy/nightwatch 2.0.0-beta.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,16 +7,8 @@
7
7
 
8
8
  ## Installation
9
9
 
10
- Using yarn:
11
-
12
10
  ```sh-session
13
- $ yarn add --dev @percy/cli @percy/nightwatch@next
14
- ```
15
-
16
- Using npm:
17
-
18
- ```sh-session
19
- $ npm install --save-dev @percy/cli @percy/nightwatch@next
11
+ $ npm install --save-dev @percy/cli @percy/nightwatch
20
12
  ```
21
13
 
22
14
  ### Nightwatch configuration
@@ -46,7 +38,7 @@ module.exports = {
46
38
  browser
47
39
  .url('http://example.com')
48
40
  .assert.containsText('h1', 'Example Domain')
49
- .percySnapshot();
41
+ .percySnapshot('Example snapshot');
50
42
  browser
51
43
  .url('http://google.com')
52
44
  .assert.elementPresent('img[alt="Google"]')
@@ -107,31 +99,37 @@ OK. 2 assertions passed.
107
99
  `percySnapshot([name][, options])`
108
100
 
109
101
  - `name` - The snapshot name; must be unique to each snapshot
110
- - `options` - Additional snapshot options (overrides any project options)
111
- - `options.widths` - An array of widths to take screenshots at
112
- - `options.minHeight` - The minimum viewport height to take screenshots at
113
- - `options.percyCSS` - Percy specific CSS only applied in Percy's rendering environment
114
- - `options.requestHeaders` - Headers that should be used during asset discovery
115
- - `options.enableJavaScript` - Enable JavaScript in Percy's rendering environment
102
+ - `options` - [See per-snapshot configuration options](https://docs.percy.io/docs/cli-configuration#per-snapshot-configuration)
116
103
 
117
104
  ## Upgrading
118
105
 
119
- If you're coming from a pre-2.0 version of this package, make sure to install `@percy/cli` after
120
- upgrading to retain any existing scripts that reference the Percy CLI command.
106
+ ### Automatically with `@percy/migrate`
121
107
 
122
- Using yarn:
108
+ We built a tool to help automate migrating to the new CLI toolchain! Migrating
109
+ can be done by running the following commands and following the prompts:
123
110
 
124
- ```sh-session
125
- $ yarn add --dev @percy/cli
111
+ ``` shell
112
+ $ npx @percy/migrate
113
+ ? Are you currently using @percy/nightwatch? Yes
114
+ ? Install @percy/cli (required to run percy)? Yes
115
+ ? Migrate Percy config file? Yes
116
+ ? Upgrade SDK to @percy/nightwatch@2.0.0? Yes
126
117
  ```
127
118
 
128
- Using npm:
119
+ This will automatically run the changes described below for you.
120
+
121
+ ### Manually
122
+
123
+ #### Installing `@percy/cli`
124
+
125
+ If you're coming from a pre-2.0 version of this package, make sure to install `@percy/cli` after
126
+ upgrading to retain any existing scripts that reference the Percy CLI command.
129
127
 
130
128
  ```sh-session
131
129
  $ npm install --save-dev @percy/cli
132
130
  ```
133
131
 
134
- ### Migrating Config
132
+ #### Migrating Config
135
133
 
136
134
  If you have a previous Percy configuration file, migrate it to the newest version with the
137
135
  [`config:migrate`](https://github.com/percy/cli/tree/master/packages/cli-config#percy-configmigrate-filepath-output) command:
@@ -1,5 +1,3 @@
1
- const utils = require('@percy/sdk-utils');
2
-
3
1
  // Collect client and environment information
4
2
  const sdkPkg = require('../package.json');
5
3
  const nightwatchPkg = require('nightwatch/package.json');
@@ -9,6 +7,8 @@ const ENV_INFO = `${nightwatchPkg.name}/${nightwatchPkg.version}`;
9
7
  // Take a DOM snapshot and post it to the snapshot endpoint
10
8
  module.exports = class PercySnapshotCommand {
11
9
  async command(name, options) {
10
+ let utils = await import('@percy/sdk-utils');
11
+
12
12
  if (!(await utils.isPercyEnabled())) return;
13
13
  name = name || this.api.currentTest.name;
14
14
  let log = utils.logger('nightwatch');
@@ -19,15 +19,18 @@ module.exports = class PercySnapshotCommand {
19
19
 
20
20
  // Serialize and capture the DOM
21
21
  /* istanbul ignore next: no instrumenting injected code */
22
- let { value: { domSnapshot, url } } = (
23
- await this.api.execute(function(options) {
22
+ let { domSnapshot, url } = await new Promise((resolve) => {
23
+ this.api.execute(function(options) {
24
24
  return {
25
25
  /* eslint-disable-next-line no-undef */
26
26
  domSnapshot: PercyDOM.serialize(options),
27
27
  url: document.URL
28
28
  };
29
- }, [options])
30
- );
29
+ }, [options], function(result) {
30
+ // Check if we're in Nightwatch 1.x (which returns with `.value`)
31
+ result.value ? resolve(result.value) : resolve(result);
32
+ });
33
+ });
31
34
 
32
35
  // Post the DOM to the snapshot endpoint with snapshot options and other info
33
36
  await utils.postSnapshot({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@percy/nightwatch",
3
3
  "description": "Nightwatch client library for visual testing with Percy",
4
- "version": "2.0.0-beta.2",
4
+ "version": "2.1.0",
5
5
  "license": "MIT",
6
6
  "author": "Perceptual Inc.",
7
7
  "repository": "https://github.com/percy/percy-nightwatch",
@@ -16,32 +16,35 @@
16
16
  "commands/percySnapshot.js",
17
17
  "types/percySnapshot.d.ts"
18
18
  ],
19
+ "engines": {
20
+ "node": ">=14"
21
+ },
19
22
  "scripts": {
20
23
  "lint": "eslint --ignore-path .gitignore .",
21
- "test": "nightwatch",
24
+ "test": "MOZ_HEADLESS=1 nightwatch",
22
25
  "test:coverage": "nyc yarn test",
23
26
  "test:types": "tsd"
24
27
  },
25
28
  "dependencies": {
26
- "@percy/sdk-utils": "~1.0.0-beta.30"
29
+ "@percy/sdk-utils": "^1.0.0"
27
30
  },
28
31
  "peerDependencies": {
29
- "nightwatch": "~1"
32
+ "nightwatch": ">=1"
30
33
  },
31
34
  "devDependencies": {
32
- "@percy/core": "~1.0.0-beta.30",
33
- "@types/nightwatch": "^1.3.1",
35
+ "@percy/core": "^1.0.0",
36
+ "@types/nightwatch": "^2.0.0",
34
37
  "eslint": "^7.11.0",
35
38
  "eslint-config-standard": "^16.0.1",
36
39
  "eslint-plugin-import": "^2.22.1",
37
40
  "eslint-plugin-node": "^11.1.0",
38
- "eslint-plugin-promise": "^4.2.1",
41
+ "eslint-plugin-promise": "^5.1.0",
39
42
  "eslint-plugin-standard": "^5.0.0",
40
- "expect": "^26.5.3",
41
- "geckodriver": "^1.20.0",
42
- "mocha": "^8.1.3",
43
- "nightwatch": "^1.5.1",
43
+ "expect": "^27.0.2",
44
+ "geckodriver": "^3.0.1",
45
+ "mocha": "^10.0.0",
46
+ "nightwatch": "^2.1.3",
44
47
  "nyc": "^15.1.0",
45
- "tsd": "^0.14.0"
48
+ "tsd": "^0.20.0"
46
49
  }
47
50
  }