@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.
@@ -1,6 +1,6 @@
1
1
  export default async function toClickButton(page, expectedText, opts) {
2
2
  try {
3
- const el = await page.waitForSelector('button::-p-text(Submit)', opts);
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
- return await evaluateWithRetryAndTimeout(page, async () => {
6
- const pathname = new URL(page.url()).pathname;
7
- return {
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
  }
@@ -1,5 +1,2 @@
1
1
  import { Page } from 'puppeteer';
2
- export default function toHavePath(page: Page, expectedPath: string): Promise<{
3
- message: () => string;
4
- pass: boolean;
5
- }>;
2
+ export default function toHavePath(page: Page, expectedPath: string): Promise<void>;
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.2",
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('button::-p-text(Submit)', opts)
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
- return await evaluateWithRetryAndTimeout(
9
- page,
10
- async () => {
11
- const pathname = new URL(page.url()).pathname
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
  }