@rvoh/psychic-spec-helpers 0.4.2 → 0.4.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/dist/esm/src/feature/matchers/toClickButton.js +1 -1
- package/dist/esm/src/feature/matchers/toHavePath.js +3 -13
- package/dist/types/src/feature/matchers/toHavePath.d.ts +1 -4
- package/package.json +1 -2
- package/src/feature/matchers/toClickButton.ts +1 -1
- package/src/feature/matchers/toHavePath.ts +5 -17
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default async function toClickButton(page, expectedText, opts) {
|
|
2
2
|
try {
|
|
3
|
-
const el = await page.waitForSelector(
|
|
3
|
+
const el = await page.waitForSelector(`button::-p-text("${expectedText}")`, opts);
|
|
4
4
|
await el.click();
|
|
5
5
|
return {
|
|
6
6
|
pass: true,
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import evaluateWithRetryAndTimeout from '../internal/evaluateWithRetryAndTimeout.js';
|
|
2
1
|
import requirePuppeteerPage from '../internal/requirePuppeteerPage.js';
|
|
3
2
|
export default async function toHavePath(page, expectedPath) {
|
|
4
3
|
requirePuppeteerPage(page);
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
pass: pathname === expectedPath,
|
|
9
|
-
actual: expectedPath,
|
|
10
|
-
};
|
|
11
|
-
}, {
|
|
12
|
-
successText: () => {
|
|
13
|
-
throw new Error('cannot negate toHavePath');
|
|
14
|
-
},
|
|
15
|
-
failureText: () => `Expected page not to have path: "${expectedPath}"`,
|
|
16
|
-
});
|
|
4
|
+
await page.waitForFunction(
|
|
5
|
+
// @ts-expect-error window
|
|
6
|
+
path => new URL(window.location.href).pathname === expectedPath, {}, expectedPath);
|
|
17
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@rvoh/psychic-spec-helpers",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.4",
|
|
5
5
|
"description": "psychic framework spec helpers",
|
|
6
6
|
"author": "RVO Health",
|
|
7
7
|
"repository": {
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"@types/supertest": "*",
|
|
34
34
|
"puppeteer": "*",
|
|
35
35
|
"supertest": "*",
|
|
36
|
-
"ts-node": "*",
|
|
37
36
|
"typescript": "*"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
@@ -6,7 +6,7 @@ export default async function toClickButton(
|
|
|
6
6
|
opts?: WaitForSelectorOptions
|
|
7
7
|
) {
|
|
8
8
|
try {
|
|
9
|
-
const el = await page.waitForSelector(
|
|
9
|
+
const el = await page.waitForSelector(`button::-p-text("${expectedText}")`, opts)
|
|
10
10
|
await el!.click()
|
|
11
11
|
|
|
12
12
|
return {
|
|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
import { Page } from 'puppeteer'
|
|
2
|
-
import evaluateWithRetryAndTimeout from '../internal/evaluateWithRetryAndTimeout.js'
|
|
3
2
|
import requirePuppeteerPage from '../internal/requirePuppeteerPage.js'
|
|
4
3
|
|
|
5
4
|
export default async function toHavePath(page: Page, expectedPath: string) {
|
|
6
5
|
requirePuppeteerPage(page)
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
pass: pathname === expectedPath,
|
|
15
|
-
actual: expectedPath,
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
successText: () => {
|
|
20
|
-
throw new Error('cannot negate toHavePath')
|
|
21
|
-
},
|
|
22
|
-
failureText: () => `Expected page not to have path: "${expectedPath}"`,
|
|
23
|
-
}
|
|
7
|
+
await page.waitForFunction(
|
|
8
|
+
// @ts-expect-error window
|
|
9
|
+
path => new URL(window.location.href).pathname === expectedPath,
|
|
10
|
+
{},
|
|
11
|
+
expectedPath
|
|
24
12
|
)
|
|
25
13
|
}
|