@percy/core 1.0.1 → 1.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/core",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,17 +17,18 @@
17
17
  "dist",
18
18
  "post-install.js",
19
19
  "types/index.d.ts",
20
- "test/helpers/server.js"
20
+ "test/helpers"
21
21
  ],
22
22
  "main": "./dist/index.js",
23
- "types": "types/index.d.ts",
23
+ "types": "./types/index.d.ts",
24
24
  "type": "module",
25
25
  "exports": {
26
26
  ".": "./dist/index.js",
27
27
  "./utils": "./dist/utils.js",
28
28
  "./config": "./dist/config.js",
29
29
  "./install": "./dist/install.js",
30
- "./test/helpers": "./test/helpers/index.js"
30
+ "./test/helpers": "./test/helpers/index.js",
31
+ "./test/helpers/server": "./test/helpers/server.js"
31
32
  },
32
33
  "scripts": {
33
34
  "build": "node ../../scripts/build",
@@ -38,10 +39,10 @@
38
39
  "test:types": "tsd"
39
40
  },
40
41
  "dependencies": {
41
- "@percy/client": "1.0.1",
42
- "@percy/config": "1.0.1",
43
- "@percy/dom": "1.0.1",
44
- "@percy/logger": "1.0.1",
42
+ "@percy/client": "1.0.4",
43
+ "@percy/config": "1.0.4",
44
+ "@percy/dom": "1.0.4",
45
+ "@percy/logger": "1.0.4",
45
46
  "content-disposition": "^0.5.4",
46
47
  "cross-spawn": "^7.0.3",
47
48
  "extract-zip": "^2.0.1",
@@ -52,5 +53,5 @@
52
53
  "rimraf": "^3.0.2",
53
54
  "ws": "^8.0.0"
54
55
  },
55
- "gitHead": "38917e6027299d6cd86008e2ccd005d90bbf89c0"
56
+ "gitHead": "db5b67f953f01c9a6d13b7a5a1d701ab983215cc"
56
57
  }
@@ -0,0 +1,27 @@
1
+ export function dedent(raw, ...values) {
2
+ let result = raw.reduce((acc, str, i) => {
3
+ acc += str.replace(/\\\n[ \t]*/g, '').replace(/\\`/g, '`');
4
+ if (i < values.length) acc += values[i];
5
+ return acc;
6
+ }, '');
7
+
8
+ let lines = result.split('\n');
9
+ let mindent;
10
+
11
+ for (let l of lines) {
12
+ let m = l.match(/^(\s+)\S+/);
13
+
14
+ if (m) {
15
+ let indent = m[1].length;
16
+ mindent = !mindent ? indent : Math.min(mindent, indent);
17
+ }
18
+ }
19
+
20
+ if (mindent != null) {
21
+ result = lines.map(l => l[0] === ' ' ? l.slice(mindent) : l).join('\n');
22
+ }
23
+
24
+ return result.trim().replace(/\\n/g, '\n');
25
+ }
26
+
27
+ export default dedent;
@@ -0,0 +1,34 @@
1
+ import { resetPercyConfig, mockfs as mfs, fs } from '@percy/config/test/helpers';
2
+ import logger from '@percy/logger/test/helpers';
3
+ import api from '@percy/client/test/helpers';
4
+ import path from 'path';
5
+ import url from 'url';
6
+
7
+ export function mockfs(initial) {
8
+ return mfs({
9
+ ...initial,
10
+
11
+ $bypass: [
12
+ path.resolve(url.fileURLToPath(import.meta.url), '/../../../dom/dist/bundle.js'),
13
+ p => p.includes?.('.local-chromium'),
14
+ ...(initial?.$bypass ?? [])
15
+ ]
16
+ });
17
+ }
18
+
19
+ export async function setupTest({
20
+ resetConfig,
21
+ filesystem,
22
+ loggerTTY,
23
+ apiDelay
24
+ } = {}) {
25
+ await api.mock({ delay: apiDelay });
26
+ await logger.mock({ isTTY: loggerTTY });
27
+ await resetPercyConfig(resetConfig);
28
+ await mockfs(filesystem);
29
+ }
30
+
31
+ export * from '@percy/client/test/helpers';
32
+ export { createTestServer } from './server.js';
33
+ export { dedent } from './dedent.js';
34
+ export { logger, fs };
@@ -0,0 +1,15 @@
1
+ export async function request(url, method = 'GET', handle) {
2
+ if (typeof method === 'boolean' || typeof method === 'function') [handle, method] = [method, 'GET'];
3
+ let cb = typeof handle === 'boolean' ? (handle ? (...a) => a : (_, r) => r) : handle;
4
+ let options = typeof method === 'string' ? { method } : method;
5
+ let { request } = await import('@percy/client/utils');
6
+
7
+ try {
8
+ return await request(url, options, cb);
9
+ } catch (error) {
10
+ if (typeof handle !== 'boolean') throw error;
11
+ return handle ? [error.response.body, error.response] : error.response;
12
+ }
13
+ }
14
+
15
+ export default request;
@@ -1,4 +1,4 @@
1
- // aliased to src for coverage during tests without needing to compile this file
1
+ // aliased to src during tests
2
2
  import Server from '../../dist/server.js';
3
3
 
4
4
  export function createTestServer({ default: defaultReply, ...replies }, port = 8000) {