@leaflink/dom-testing-utils 1.3.0 → 2.0.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 +29 -12
- package/dist/index.d.ts +3 -3
- package/dist/index.js +11 -9
- package/dist/index.js.map +1 -1
- package/dist/index.spec.js +20 -12
- package/dist/index.spec.js.map +1 -1
- package/dist/setup-env.js +4 -4
- package/dist/setup-env.js.map +1 -1
- package/package.json +36 -24
package/README.md
CHANGED
|
@@ -13,12 +13,15 @@
|
|
|
13
13
|
|
|
14
14
|
- [Installation](#installation)
|
|
15
15
|
- [Usage](#usage)
|
|
16
|
-
- [Global setup](#global-setup)
|
|
17
16
|
- [Setup file](#setup-file)
|
|
17
|
+
- [Global setup](#global-setup)
|
|
18
|
+
- [Utilities](#utilities)
|
|
18
19
|
- [`cleanupNoty`](#cleanupnoty)
|
|
19
20
|
- [`waitForLoadingToFinish`](#waitforloadingtofinish)
|
|
20
21
|
- [`cleanupDropdowns`](#cleanupdropdowns)
|
|
21
22
|
- [`assertAndDismissNoty`](#assertanddismissnoty)
|
|
23
|
+
- [`getByDescriptionTerm`](#getbydescriptionterm)
|
|
24
|
+
- [`getAllByDescriptionTerm`](#getallbydescriptionterm)
|
|
22
25
|
- [`createFixtureGenerator`](#createfixturegenerator)
|
|
23
26
|
- [Mocking API Endpoints](#mocking-api-endpoints)
|
|
24
27
|
|
|
@@ -32,7 +35,7 @@ npm install --save-dev @leaflink/dom-testing-utils
|
|
|
32
35
|
|
|
33
36
|
## Usage
|
|
34
37
|
|
|
35
|
-
In your
|
|
38
|
+
In your test files you can import utility functions.
|
|
36
39
|
|
|
37
40
|
```ts
|
|
38
41
|
import {
|
|
@@ -48,27 +51,41 @@ it('...', () => {
|
|
|
48
51
|
});
|
|
49
52
|
```
|
|
50
53
|
|
|
51
|
-
|
|
54
|
+
### Setup file
|
|
52
55
|
|
|
53
|
-
|
|
56
|
+
Import `@leaflink/dom-testing-utils/setup-env` once (for instance in your tests setup file) and you're good to go:
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
> **Note:** `@testing-library/jest-dom` is auto-imported from `@leaflink/dom-testing-utils` so you don't have to.
|
|
56
59
|
|
|
57
|
-
```
|
|
58
|
-
|
|
60
|
+
```ts
|
|
61
|
+
// In your own setup-env.ts (or any other name)
|
|
62
|
+
import '@leaflink/dom-testing-utils/setup-env'
|
|
63
|
+
// DON'T import `@testing-library/jest-dom` is auto imported from dom-testing-utils
|
|
64
|
+
|
|
65
|
+
// In vite.config.ts add (if you haven't already)
|
|
66
|
+
setupFiles: ['tests/setup-env.js'],
|
|
67
|
+
|
|
68
|
+
// In jest.config.js add (if you haven't already)
|
|
69
|
+
setupFilesAfterEnv: ['<rootDir>/tests/setup-env.js']
|
|
59
70
|
```
|
|
60
71
|
|
|
61
|
-
This will run once
|
|
72
|
+
This will be run once before *each* test file. See <https://vitest.dev/config/#setupfiles>.
|
|
62
73
|
|
|
63
|
-
###
|
|
74
|
+
### Global setup
|
|
64
75
|
|
|
65
|
-
Add the following
|
|
76
|
+
Add the following import to your test config:
|
|
66
77
|
|
|
67
78
|
```js
|
|
68
|
-
|
|
79
|
+
// In vite.config.ts add
|
|
80
|
+
globalSetup: ['node_modules/@leaflink/dom-testing-utils/dist/global-setup.js'],
|
|
81
|
+
|
|
82
|
+
// In jest.config.js add
|
|
83
|
+
globalSetup: ['<rootDir>/node_modules/@leaflink/dom-testing-utils/dist/global-setup.js']
|
|
69
84
|
```
|
|
70
85
|
|
|
71
|
-
This will
|
|
86
|
+
This will run once *before everything*. See <https://vitest.dev/config/#globalsetup>.
|
|
87
|
+
|
|
88
|
+
## Utilities
|
|
72
89
|
|
|
73
90
|
### `cleanupNoty`
|
|
74
91
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createMockApiUtils, RestMethod } from
|
|
1
|
+
import { createMockApiUtils, RestMethod } from './api/mockEndpoints.js';
|
|
2
2
|
/**
|
|
3
3
|
* Utility to wait for loading to complete. Need to add a `data-test` to any
|
|
4
4
|
* loading elements. Defaults to `ll-loading` OR `loading-spinner` if test ID is not specified.
|
|
@@ -62,7 +62,7 @@ export declare function assertAndDismissNoty(text: string): Promise<void>;
|
|
|
62
62
|
export declare function createFixtureGenerator<T>(fixtureFn: (overrides?: Partial<T>) => T): {
|
|
63
63
|
(): T;
|
|
64
64
|
<TNum extends 1>(num: TNum, overrides?: Partial<T>): T;
|
|
65
|
-
|
|
66
|
-
<
|
|
65
|
+
(num: Partial<T>): T;
|
|
66
|
+
<TNum_1 extends number>(num: TNum_1, overrides?: Partial<T>): T[];
|
|
67
67
|
};
|
|
68
68
|
export { createMockApiUtils, RestMethod };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { createMockApiUtils } from
|
|
1
|
+
import userEvent from '@testing-library/user-event';
|
|
2
|
+
import { getNodeText, screen, waitForElementToBeRemoved, } from '@testing-library/vue';
|
|
3
|
+
import { createMockApiUtils } from './api/mockEndpoints.js';
|
|
4
4
|
/**
|
|
5
5
|
* Utility to wait for loading to complete. Need to add a `data-test` to any
|
|
6
6
|
* loading elements. Defaults to `ll-loading` OR `loading-spinner` if test ID is not specified.
|
|
@@ -8,7 +8,7 @@ import { createMockApiUtils } from "./api/mockEndpoints.js";
|
|
|
8
8
|
* @param {string} testId - The data test ID to target
|
|
9
9
|
* @returns {Promise<boolean>} - Will resolve or throw if the loaders stay in the DOM.
|
|
10
10
|
*/
|
|
11
|
-
export function waitForLoadingToFinish(textMatch = /ll
|
|
11
|
+
export function waitForLoadingToFinish(textMatch = /ll-loading|loading-spinner/) {
|
|
12
12
|
return waitForElementToBeRemoved(() => [...screen.queryAllByTestId(textMatch)], { timeout: 2000 });
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
@@ -59,9 +59,10 @@ function hasText(node, textMatch) {
|
|
|
59
59
|
export function getAllByDescriptionTerm(textMatch) {
|
|
60
60
|
return screen
|
|
61
61
|
.getAllByRole('definition')
|
|
62
|
-
.filter((term) => term.tagName === 'DD' &&
|
|
62
|
+
.filter((term) => term.tagName === 'DD' &&
|
|
63
|
+
isHTMLElement(term.previousElementSibling) &&
|
|
64
|
+
hasText(term?.previousElementSibling, textMatch));
|
|
63
65
|
}
|
|
64
|
-
;
|
|
65
66
|
/**
|
|
66
67
|
* Finds the first HTML element with the role "definition" (DD) that matches the specified text.
|
|
67
68
|
*
|
|
@@ -71,9 +72,10 @@ export function getAllByDescriptionTerm(textMatch) {
|
|
|
71
72
|
export function getByDescriptionTerm(textMatch) {
|
|
72
73
|
return screen
|
|
73
74
|
.getAllByRole('definition')
|
|
74
|
-
.find((term) => term.tagName === 'DD' &&
|
|
75
|
+
.find((term) => term.tagName === 'DD' &&
|
|
76
|
+
isHTMLElement(term.previousElementSibling) &&
|
|
77
|
+
hasText(term?.previousElementSibling, textMatch));
|
|
75
78
|
}
|
|
76
|
-
;
|
|
77
79
|
/**
|
|
78
80
|
* Helper to assert and manually dismiss a notification. This is useful in scenarios where
|
|
79
81
|
* cleanupNoty() does not work as expected, such as when validating error messages in test suites
|
|
@@ -120,10 +122,10 @@ export function createFixtureGenerator(fixtureFn) {
|
|
|
120
122
|
}
|
|
121
123
|
else {
|
|
122
124
|
// Otherwise, let's generate however many requested data objects
|
|
125
|
+
// eslint-disable-next-line prefer-spread
|
|
123
126
|
return Array.apply(null, Array(num)).map(() => fixtureFn(overrides));
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
|
-
;
|
|
127
129
|
return _generator;
|
|
128
130
|
}
|
|
129
131
|
export { createMockApiUtils };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO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AAS,CAAC,SAAS,CAAC,CAAC,CAAC;SACtE;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAc,CAAC"}
|
package/dist/index.spec.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { render } from '@testing-library/vue';
|
|
2
|
-
import { createFixtureGenerator, getByDescriptionTerm,
|
|
2
|
+
import { createFixtureGenerator, getAllByDescriptionTerm, getByDescriptionTerm, } from './index';
|
|
3
3
|
describe('createFixtureGenerator()', () => {
|
|
4
4
|
it('returns a function that can generate an array of data objects', () => {
|
|
5
5
|
const generator = (overrides) => ({
|
|
@@ -26,16 +26,22 @@ describe('createFixtureGenerator()', () => {
|
|
|
26
26
|
bar: 'baz',
|
|
27
27
|
...overrides,
|
|
28
28
|
});
|
|
29
|
-
expect(createFixtureGenerator(generator)()).toEqual({
|
|
30
|
-
|
|
29
|
+
expect(createFixtureGenerator(generator)()).toEqual({
|
|
30
|
+
foo: 'bar',
|
|
31
|
+
bar: 'baz',
|
|
32
|
+
});
|
|
33
|
+
expect(createFixtureGenerator(generator)({ bar: 'yak' })).toEqual({
|
|
34
|
+
foo: 'bar',
|
|
35
|
+
bar: 'yak',
|
|
36
|
+
});
|
|
31
37
|
});
|
|
32
38
|
});
|
|
33
39
|
describe('getByDescriptionTerm', () => {
|
|
34
40
|
it.each `
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
term | type
|
|
42
|
+
${'foo'} | ${'string'}
|
|
43
|
+
${/foo/i} | ${'regex'}
|
|
44
|
+
${new RegExp('foo', 'i')} | ${'RegExp'}
|
|
39
45
|
`('should return the description detail for a given $type term', ({ term }) => {
|
|
40
46
|
render({ template: `<dl><dt>foo</dt><dd>bar</dd></dl>` });
|
|
41
47
|
expect(getByDescriptionTerm(term)).toHaveTextContent('bar');
|
|
@@ -43,12 +49,14 @@ describe('getByDescriptionTerm', () => {
|
|
|
43
49
|
});
|
|
44
50
|
describe('getAllByDescriptionTerm', () => {
|
|
45
51
|
it.each `
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
term | type
|
|
53
|
+
${'foo'} | ${'string'}
|
|
54
|
+
${/foo/i} | ${'regex'}
|
|
55
|
+
${new RegExp('foo', 'i')} | ${'RegExp'}
|
|
50
56
|
`('should return the description details for a given $type term', ({ term }) => {
|
|
51
|
-
render({
|
|
57
|
+
render({
|
|
58
|
+
template: `<dl><dt>foo</dt><dd>bar1</dd></dl><dl><dt>foo</dt><dd>bar2</dd></dl>`,
|
|
59
|
+
});
|
|
52
60
|
const details = getAllByDescriptionTerm(term);
|
|
53
61
|
expect(details).toHaveLength(2);
|
|
54
62
|
expect(details[0]).toHaveTextContent('bar1');
|
package/dist/index.spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.js","sourceRoot":"src/","sources":["index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.spec.js","sourceRoot":"src/","sources":["index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,SAAS,CAAC;AAEjB,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;QACvE,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YAChC,GAAG,EAAE,KAAK;YACV,GAAG,EAAE,KAAK;YACV,GAAG,SAAS;SACb,CAAC,CAAC;QAEH,MAAM,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YACnD,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,E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AAC,IAAI,CAAA;;MAEH,KAAK,uBAAuB,QAAQ;MACpC,MAAM,sBAAsB,OAAO;MACnC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,QAAQ;GACvC,CACC,6DAA6D,EAC7D,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;QACX,MAAM,CAAC,EAAE,QAAQ,EAAE,mCAAmC,EAAE,CAAC,CAAC;QAE1D,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,IAAI,CAAA;;MAEH,KAAK,uBAAuB,QAAQ;MACpC,MAAM,sBAAsB,OAAO;MACnC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,QAAQ;GACvC,CACC,8DAA8D,EAC9D,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;QACX,MAAM,CAAC;YACL,QAAQ,EAAE,sEAAsE;SACjF,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;QAC9C,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/setup-env.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { vi } from 'vitest';
|
|
2
|
-
import { config } from '@vue/test-utils';
|
|
3
1
|
import '@testing-library/jest-dom';
|
|
2
|
+
import { config } from '@vue/test-utils';
|
|
3
|
+
import { vi } from 'vitest';
|
|
4
4
|
config.global.mocks['$t'] = (msg) => msg;
|
|
5
5
|
const oldWindowLocation = global.window.location;
|
|
6
6
|
beforeAll(() => {
|
|
7
|
-
// @ts-expect-error
|
|
7
|
+
// @ts-expect-error - dunno
|
|
8
8
|
delete global.window.location;
|
|
9
|
-
// @ts-expect-error
|
|
9
|
+
// @ts-expect-error - dunno
|
|
10
10
|
global.window.location = Object.defineProperties({}, {
|
|
11
11
|
...Object.getOwnPropertyDescriptors(oldWindowLocation),
|
|
12
12
|
assign: {
|
package/dist/setup-env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-env.js","sourceRoot":"src/","sources":["setup-env.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"setup-env.js","sourceRoot":"src/","sources":["setup-env.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC;AAEzC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;AAEjD,SAAS,CAAC,GAAG,EAAE;IACb,2BAA2B;IAC3B,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;IAE9B,2BAA2B;IAC3B,MAAM,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAC9C,EAAE,EACF;QACE,GAAG,MAAM,CAAC,yBAAyB,CAAC,iBAAiB,CAAC;QACtD,MAAM,EAAE;YACN,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;SACf;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,IAAI;YAClB,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
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Frontend DOM testing utilities",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16",
|
|
7
7
|
"npm": ">=8"
|
|
8
8
|
},
|
|
9
9
|
"exports": {
|
|
10
|
-
".":
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./setup-env": {
|
|
16
|
+
"types": "./dist/setup-env.d.ts",
|
|
17
|
+
"import": "./dist/setup-env.js",
|
|
18
|
+
"default": "./dist/setup-env.js"
|
|
19
|
+
},
|
|
20
|
+
"./global-env": {
|
|
21
|
+
"types": "./dist/global-env.d.ts",
|
|
22
|
+
"import": "./dist/global-env.js",
|
|
23
|
+
"default": "./dist/global-env.js"
|
|
24
|
+
}
|
|
11
25
|
},
|
|
12
26
|
"type": "module",
|
|
13
27
|
"types": "./dist/index.d.ts",
|
|
@@ -19,32 +33,12 @@
|
|
|
19
33
|
],
|
|
20
34
|
"scripts": {
|
|
21
35
|
"build": "tsc",
|
|
36
|
+
"fix": "npm run lint -- --fix",
|
|
37
|
+
"lint": "eslint .",
|
|
22
38
|
"lint:commits": "commitlint",
|
|
23
39
|
"test": "vitest --reporter verbose"
|
|
24
40
|
},
|
|
25
41
|
"license": "MIT",
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@commitlint/cli": "^17.4.4",
|
|
28
|
-
"@commitlint/config-conventional": "^17.4.4",
|
|
29
|
-
"@vitest/coverage-c8": "^0.29.2",
|
|
30
|
-
"jsdom": "^21.1.1",
|
|
31
|
-
"typescript": "^4.9.5",
|
|
32
|
-
"vite": "^4.1.4",
|
|
33
|
-
"vitest": "^0.29.3"
|
|
34
|
-
},
|
|
35
|
-
"commitlint": {
|
|
36
|
-
"extends": [
|
|
37
|
-
"@commitlint/config-conventional"
|
|
38
|
-
],
|
|
39
|
-
"rules": {
|
|
40
|
-
"scope-case": [
|
|
41
|
-
0
|
|
42
|
-
],
|
|
43
|
-
"body-max-line-length": [
|
|
44
|
-
0
|
|
45
|
-
]
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
42
|
"dependencies": {
|
|
49
43
|
"@testing-library/cypress": "^9.0.0",
|
|
50
44
|
"@testing-library/jest-dom": "^5.16.5",
|
|
@@ -53,5 +47,23 @@
|
|
|
53
47
|
"@types/segment-analytics": "^0.0.34",
|
|
54
48
|
"eslint-plugin-testing-library": "^5.10.2",
|
|
55
49
|
"msw": "^0.27.2"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@vitest/coverage-c8": "^0.29.2",
|
|
53
|
+
"eslint": "^8.49.0",
|
|
54
|
+
"eslint-config-leaflink": "^1.17.0",
|
|
55
|
+
"jsdom": "^21.1.1",
|
|
56
|
+
"postcss-html": "^1.5.0",
|
|
57
|
+
"stylelint": "^15.10.3",
|
|
58
|
+
"stylelint-config-standard-scss": "^10.0.0",
|
|
59
|
+
"stylelint-config-standard-vue": "^1.0.0",
|
|
60
|
+
"typescript": "^4.9.5",
|
|
61
|
+
"vite": "^4.1.4",
|
|
62
|
+
"vitest": "^0.29.3"
|
|
63
|
+
},
|
|
64
|
+
"eslintConfig": {
|
|
65
|
+
"extends": [
|
|
66
|
+
"leaflink"
|
|
67
|
+
]
|
|
56
68
|
}
|
|
57
69
|
}
|