@percy/nightwatch 2.0.0 → 2.1.1

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
@@ -99,12 +99,7 @@ OK. 2 assertions passed.
99
99
  `percySnapshot([name][, options])`
100
100
 
101
101
  - `name` - The snapshot name; must be unique to each snapshot
102
- - `options` - Additional snapshot options (overrides any project options)
103
- - `options.widths` - An array of widths to take screenshots at
104
- - `options.minHeight` - The minimum viewport height to take screenshots at
105
- - `options.percyCSS` - Percy specific CSS only applied in Percy's rendering environment
106
- - `options.requestHeaders` - Headers that should be used during asset discovery
107
- - `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)
108
103
 
109
104
  ## Upgrading
110
105
 
@@ -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",
4
+ "version": "2.1.1",
5
5
  "license": "MIT",
6
6
  "author": "Perceptual Inc.",
7
7
  "repository": "https://github.com/percy/percy-nightwatch",
@@ -17,34 +17,34 @@
17
17
  "types/percySnapshot.d.ts"
18
18
  ],
19
19
  "engines": {
20
- "node": ">=12"
20
+ "node": ">=14"
21
21
  },
22
22
  "scripts": {
23
23
  "lint": "eslint --ignore-path .gitignore .",
24
- "test": "nightwatch",
24
+ "test": "MOZ_HEADLESS=1 percy exec --testing -- nightwatch",
25
25
  "test:coverage": "nyc yarn test",
26
26
  "test:types": "tsd"
27
27
  },
28
28
  "dependencies": {
29
- "@percy/sdk-utils": "~1.0.0-beta.32"
29
+ "@percy/sdk-utils": "^1.0.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "nightwatch": "~1"
32
+ "nightwatch": ">=1 || >=2"
33
33
  },
34
34
  "devDependencies": {
35
- "@percy/core": "~1.0.0-beta.32",
36
- "@types/nightwatch": "^1.3.1",
35
+ "@percy/cli": "^1.9.1",
36
+ "@types/nightwatch": "^2.0.0",
37
37
  "eslint": "^7.11.0",
38
38
  "eslint-config-standard": "^16.0.1",
39
39
  "eslint-plugin-import": "^2.22.1",
40
40
  "eslint-plugin-node": "^11.1.0",
41
- "eslint-plugin-promise": "^4.2.1",
41
+ "eslint-plugin-promise": "^5.1.0",
42
42
  "eslint-plugin-standard": "^5.0.0",
43
- "expect": "^26.5.3",
44
- "geckodriver": "^1.20.0",
45
- "mocha": "^8.1.3",
46
- "nightwatch": "^1.5.1",
43
+ "expect": "^27.0.2",
44
+ "geckodriver": "^3.0.1",
45
+ "mocha": "^10.0.0",
46
+ "nightwatch": "^2.3.0",
47
47
  "nyc": "^15.1.0",
48
- "tsd": "^0.14.0"
48
+ "tsd": "^0.22.0"
49
49
  }
50
50
  }