@rvoh/psychic-spec-helpers 0.4.1 → 0.4.2

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.
Files changed (26) hide show
  1. package/dist/esm/src/feature/helpers/matcher-globals/check.js +3 -0
  2. package/dist/esm/src/feature/helpers/matcher-globals/click.js +3 -0
  3. package/dist/esm/src/feature/helpers/matcher-globals/clickButton.js +3 -0
  4. package/dist/esm/src/feature/helpers/matcher-globals/clickLink.js +3 -0
  5. package/dist/esm/src/feature/helpers/matcher-globals/clickSelector.js +3 -0
  6. package/dist/esm/src/feature/helpers/matcher-globals/fillIn.js +3 -0
  7. package/dist/esm/src/feature/helpers/matcher-globals/uncheck.js +3 -0
  8. package/dist/esm/src/feature/helpers/providePuppeteerViteMatchers.js +27 -10
  9. package/dist/types/src/feature/helpers/matcher-globals/check.d.ts +2 -0
  10. package/dist/types/src/feature/helpers/matcher-globals/click.d.ts +2 -0
  11. package/dist/types/src/feature/helpers/matcher-globals/clickButton.d.ts +2 -0
  12. package/dist/types/src/feature/helpers/matcher-globals/clickLink.d.ts +2 -0
  13. package/dist/types/src/feature/helpers/matcher-globals/clickSelector.d.ts +2 -0
  14. package/dist/types/src/feature/helpers/matcher-globals/fillIn.d.ts +2 -0
  15. package/dist/types/src/feature/helpers/matcher-globals/uncheck.d.ts +2 -0
  16. package/dist/types/src/index.d.ts +9 -1
  17. package/package.json +8 -3
  18. package/src/feature/helpers/matcher-globals/check.ts +5 -0
  19. package/src/feature/helpers/matcher-globals/click.ts +5 -0
  20. package/src/feature/helpers/matcher-globals/clickButton.ts +5 -0
  21. package/src/feature/helpers/matcher-globals/clickLink.ts +5 -0
  22. package/src/feature/helpers/matcher-globals/clickSelector.ts +5 -0
  23. package/src/feature/helpers/matcher-globals/fillIn.ts +5 -0
  24. package/src/feature/helpers/matcher-globals/uncheck.ts +5 -0
  25. package/src/feature/helpers/providePuppeteerViteMatchers.ts +33 -10
  26. package/src/index.ts +9 -1
@@ -0,0 +1,3 @@
1
+ export default async function check(expectedText, opts) {
2
+ await expect(page).toCheck(expectedText, opts);
3
+ }
@@ -0,0 +1,3 @@
1
+ export default async function click(selector, opts) {
2
+ await expect(page).toClick(selector, opts);
3
+ }
@@ -0,0 +1,3 @@
1
+ export default async function clickButton(expectedText, opts) {
2
+ await expect(page).toClickButton(expectedText, opts);
3
+ }
@@ -0,0 +1,3 @@
1
+ export default async function clickLink(expectedText, opts) {
2
+ await expect(page).toClickLink(expectedText, opts);
3
+ }
@@ -0,0 +1,3 @@
1
+ export default async function clickSelector(selector, opts) {
2
+ await expect(page).toClickSelector(selector, opts);
3
+ }
@@ -0,0 +1,3 @@
1
+ export default async function fillIn(cssSelector, text, opts) {
2
+ await expect(page).toFill(cssSelector, text, opts);
3
+ }
@@ -0,0 +1,3 @@
1
+ export default async function uncheck(expectedText, opts) {
2
+ await expect(page).toUncheck(expectedText, opts);
3
+ }
@@ -1,20 +1,28 @@
1
1
  import evaluateWithRetryAndTimeout from '../internal/evaluateWithRetryAndTimeout.js';
2
- import toHaveSelector from '../matchers/toHaveSelector.js';
3
- import toMatchTextContent from '../matchers/toMatchTextContent.js';
4
- import toNotHaveSelector from '../matchers/toNotHaveSelector.js';
5
- import toNotMatchTextContent from '../matchers/toNotMatchTextContent.js';
6
2
  import toCheck from '../matchers/toCheck.js';
7
- import toUncheck from '../matchers/toUncheck.js';
8
3
  import toClick from '../matchers/toClick.js';
9
- import toClickLink from '../matchers/toClickLink.js';
10
4
  import toClickButton from '../matchers/toClickButton.js';
5
+ import toClickLink from '../matchers/toClickLink.js';
11
6
  import toClickSelector from '../matchers/toClickSelector.js';
12
- import toHavePath from '../matchers/toHavePath.js';
13
- import toHaveUrl from '../matchers/toHaveUrl.js';
14
- import toHaveLink from '../matchers/toHaveLink.js';
7
+ import toFill from '../matchers/toFill.js';
15
8
  import toHaveChecked from '../matchers/toHaveChecked.js';
9
+ import toHaveLink from '../matchers/toHaveLink.js';
10
+ import toHavePath from '../matchers/toHavePath.js';
11
+ import toHaveSelector from '../matchers/toHaveSelector.js';
16
12
  import toHaveUnchecked from '../matchers/toHaveUnchecked.js';
17
- import toFill from '../matchers/toFill.js';
13
+ import toHaveUrl from '../matchers/toHaveUrl.js';
14
+ import toMatchTextContent from '../matchers/toMatchTextContent.js';
15
+ import toNotHaveSelector from '../matchers/toNotHaveSelector.js';
16
+ import toNotMatchTextContent from '../matchers/toNotMatchTextContent.js';
17
+ import toUncheck from '../matchers/toUncheck.js';
18
+ import check from './matcher-globals/check.js';
19
+ import click from './matcher-globals/click.js';
20
+ import clickButton from './matcher-globals/clickButton.js';
21
+ import clickLink from './matcher-globals/clickLink.js';
22
+ import clickSelector from './matcher-globals/clickSelector.js';
23
+ import fillIn from './matcher-globals/fillIn.js';
24
+ import uncheck from './matcher-globals/uncheck.js';
25
+ import visit from './visit.js';
18
26
  export default function providePuppeteerViteMatchers() {
19
27
  ;
20
28
  global.expect.extend({
@@ -70,4 +78,13 @@ export default function providePuppeteerViteMatchers() {
70
78
  return await evaluateWithRetryAndTimeout(argumentPassedToExpect, evaluationFn, opts);
71
79
  },
72
80
  });
81
+ global.context ||= describe;
82
+ global.check = check;
83
+ global.click = click;
84
+ global.clickButton = clickButton;
85
+ global.clickLink = clickLink;
86
+ global.clickSelector = clickSelector;
87
+ global.fillIn = fillIn;
88
+ global.uncheck = uncheck;
89
+ global.visit = visit;
73
90
  }
@@ -0,0 +1,2 @@
1
+ import { WaitForSelectorOptions } from 'puppeteer';
2
+ export default function check(expectedText: string, opts?: WaitForSelectorOptions): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { WaitForSelectorOptions } from 'puppeteer';
2
+ export default function click(selector: string, opts?: WaitForSelectorOptions): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { WaitForSelectorOptions } from 'puppeteer';
2
+ export default function clickButton(expectedText: string, opts?: WaitForSelectorOptions): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { WaitForSelectorOptions } from 'puppeteer';
2
+ export default function clickLink(expectedText: string, opts?: WaitForSelectorOptions): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { WaitForSelectorOptions } from 'puppeteer';
2
+ export default function clickSelector(selector: string, opts?: WaitForSelectorOptions): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { ToFillMatcherOpts } from '../../matchers/toFill.js';
2
+ export default function fillIn(cssSelector: string, text: string, opts?: ToFillMatcherOpts): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { WaitForSelectorOptions } from 'puppeteer';
2
+ export default function uncheck(expectedText: string, opts?: WaitForSelectorOptions): Promise<void>;
@@ -12,8 +12,16 @@ export { default as launchPage } from './feature/helpers/launchPage.js';
12
12
  export { default as launchDevServer, stopDevServers, stopDevServer, } from './feature/helpers/launchDevServer.js';
13
13
  export { default as visit } from './feature/helpers/visit.js';
14
14
  declare global {
15
- function context(description: string, callback: () => void): void;
15
+ const context: (typeof import('vitest'))['describe'];
16
16
  const page: InstanceType<typeof Page>;
17
+ const visit: (typeof import('./feature/helpers/visit.js'))['default'];
18
+ const check: (typeof import('./feature/helpers/matcher-globals/check.js'))['default'];
19
+ const click: (typeof import('./feature/helpers/matcher-globals/click.js'))['default'];
20
+ const clickButton: (typeof import('./feature/helpers/matcher-globals/clickButton.js'))['default'];
21
+ const clickLink: (typeof import('./feature/helpers/matcher-globals/clickLink.js'))['default'];
22
+ const clickSelector: (typeof import('./feature/helpers/matcher-globals/clickSelector.js'))['default'];
23
+ const fillIn: (typeof import('./feature/helpers/matcher-globals/fillIn.js'))['default'];
24
+ const uncheck: (typeof import('./feature/helpers/matcher-globals/uncheck.js'))['default'];
17
25
  }
18
26
  declare module 'vitest' {
19
27
  interface ExpectStatic extends PuppeteerAssertions {
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@rvoh/psychic-spec-helpers",
4
- "version": "0.4.1",
4
+ "version": "0.4.2",
5
5
  "description": "psychic framework spec helpers",
6
+ "author": "RVO Health",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/rvohealth/psychic-spec-helpers.git"
10
+ },
6
11
  "main": "./dist/cjs/src/index.js",
7
12
  "module": "./dist/esm/src/index.js",
8
13
  "types": "./dist/types/src/index.d.ts",
@@ -39,9 +44,9 @@
39
44
  "supertest": "^7.0.0",
40
45
  "ts-node": "^10.9.2",
41
46
  "typescript": "^5.5.4",
42
- "vitest": "^3.0.8"
47
+ "vitest": "^3.1.1"
43
48
  },
44
49
  "dependencies": {
45
50
  "cookiejar": "^2.1.4"
46
51
  }
47
- }
52
+ }
@@ -0,0 +1,5 @@
1
+ import { WaitForSelectorOptions } from 'puppeteer'
2
+
3
+ export default async function check(expectedText: string, opts?: WaitForSelectorOptions) {
4
+ await expect(page).toCheck(expectedText, opts)
5
+ }
@@ -0,0 +1,5 @@
1
+ import { WaitForSelectorOptions } from 'puppeteer'
2
+
3
+ export default async function click(selector: string, opts?: WaitForSelectorOptions) {
4
+ await expect(page).toClick(selector, opts)
5
+ }
@@ -0,0 +1,5 @@
1
+ import { WaitForSelectorOptions } from 'puppeteer'
2
+
3
+ export default async function clickButton(expectedText: string, opts?: WaitForSelectorOptions) {
4
+ await expect(page).toClickButton(expectedText, opts)
5
+ }
@@ -0,0 +1,5 @@
1
+ import { WaitForSelectorOptions } from 'puppeteer'
2
+
3
+ export default async function clickLink(expectedText: string, opts?: WaitForSelectorOptions) {
4
+ await expect(page).toClickLink(expectedText, opts)
5
+ }
@@ -0,0 +1,5 @@
1
+ import { WaitForSelectorOptions } from 'puppeteer'
2
+
3
+ export default async function clickSelector(selector: string, opts?: WaitForSelectorOptions) {
4
+ await expect(page).toClickSelector(selector, opts)
5
+ }
@@ -0,0 +1,5 @@
1
+ import { ToFillMatcherOpts } from '../../matchers/toFill.js'
2
+
3
+ export default async function fillIn(cssSelector: string, text: string, opts?: ToFillMatcherOpts) {
4
+ await expect(page).toFill(cssSelector, text, opts)
5
+ }
@@ -0,0 +1,5 @@
1
+ import { WaitForSelectorOptions } from 'puppeteer'
2
+
3
+ export default async function uncheck(expectedText: string, opts?: WaitForSelectorOptions) {
4
+ await expect(page).toUncheck(expectedText, opts)
5
+ }
@@ -3,22 +3,30 @@ import evaluateWithRetryAndTimeout, {
3
3
  ExpectToEvaluateOpts,
4
4
  ExpectToEvaluateReturnType,
5
5
  } from '../internal/evaluateWithRetryAndTimeout.js'
6
- import toHaveSelector from '../matchers/toHaveSelector.js'
7
- import toMatchTextContent from '../matchers/toMatchTextContent.js'
8
- import toNotHaveSelector from '../matchers/toNotHaveSelector.js'
9
- import toNotMatchTextContent from '../matchers/toNotMatchTextContent.js'
10
6
  import toCheck from '../matchers/toCheck.js'
11
- import toUncheck from '../matchers/toUncheck.js'
12
7
  import toClick from '../matchers/toClick.js'
13
- import toClickLink from '../matchers/toClickLink.js'
14
8
  import toClickButton from '../matchers/toClickButton.js'
9
+ import toClickLink from '../matchers/toClickLink.js'
15
10
  import toClickSelector from '../matchers/toClickSelector.js'
16
- import toHavePath from '../matchers/toHavePath.js'
17
- import toHaveUrl from '../matchers/toHaveUrl.js'
18
- import toHaveLink from '../matchers/toHaveLink.js'
11
+ import toFill, { ToFillMatcherOpts } from '../matchers/toFill.js'
19
12
  import toHaveChecked from '../matchers/toHaveChecked.js'
13
+ import toHaveLink from '../matchers/toHaveLink.js'
14
+ import toHavePath from '../matchers/toHavePath.js'
15
+ import toHaveSelector from '../matchers/toHaveSelector.js'
20
16
  import toHaveUnchecked from '../matchers/toHaveUnchecked.js'
21
- import toFill, { ToFillMatcherOpts } from '../matchers/toFill.js'
17
+ import toHaveUrl from '../matchers/toHaveUrl.js'
18
+ import toMatchTextContent from '../matchers/toMatchTextContent.js'
19
+ import toNotHaveSelector from '../matchers/toNotHaveSelector.js'
20
+ import toNotMatchTextContent from '../matchers/toNotMatchTextContent.js'
21
+ import toUncheck from '../matchers/toUncheck.js'
22
+ import check from './matcher-globals/check.js'
23
+ import click from './matcher-globals/click.js'
24
+ import clickButton from './matcher-globals/clickButton.js'
25
+ import clickLink from './matcher-globals/clickLink.js'
26
+ import clickSelector from './matcher-globals/clickSelector.js'
27
+ import fillIn from './matcher-globals/fillIn.js'
28
+ import uncheck from './matcher-globals/uncheck.js'
29
+ import visit from './visit.js'
22
30
 
23
31
  export default function providePuppeteerViteMatchers() {
24
32
  ;((global as any).expect as any).extend({
@@ -98,6 +106,21 @@ export default function providePuppeteerViteMatchers() {
98
106
  return await evaluateWithRetryAndTimeout(argumentPassedToExpect, evaluationFn, opts)
99
107
  },
100
108
  })
109
+
110
+ // set globals
111
+
112
+ // define global context variable, setting it equal to describe
113
+ ;(global as any).context ||= describe
114
+
115
+ // define global helper functions
116
+ ;(global as any).check = check
117
+ ;(global as any).click = click
118
+ ;(global as any).clickButton = clickButton
119
+ ;(global as any).clickLink = clickLink
120
+ ;(global as any).clickSelector = clickSelector
121
+ ;(global as any).fillIn = fillIn
122
+ ;(global as any).uncheck = uncheck
123
+ ;(global as any).visit = visit
101
124
  }
102
125
 
103
126
  export interface CustomMatcherResult {
package/src/index.ts CHANGED
@@ -21,8 +21,16 @@ export {
21
21
  export { default as visit } from './feature/helpers/visit.js'
22
22
 
23
23
  declare global {
24
- function context(description: string, callback: () => void): void
24
+ const context: (typeof import('vitest'))['describe']
25
25
  const page: InstanceType<typeof Page>
26
+ const visit: (typeof import('./feature/helpers/visit.js'))['default']
27
+ const check: (typeof import('./feature/helpers/matcher-globals/check.js'))['default']
28
+ const click: (typeof import('./feature/helpers/matcher-globals/click.js'))['default']
29
+ const clickButton: (typeof import('./feature/helpers/matcher-globals/clickButton.js'))['default']
30
+ const clickLink: (typeof import('./feature/helpers/matcher-globals/clickLink.js'))['default']
31
+ const clickSelector: (typeof import('./feature/helpers/matcher-globals/clickSelector.js'))['default']
32
+ const fillIn: (typeof import('./feature/helpers/matcher-globals/fillIn.js'))['default']
33
+ const uncheck: (typeof import('./feature/helpers/matcher-globals/uncheck.js'))['default']
26
34
  }
27
35
 
28
36
  declare module 'vitest' {