@quickpickle/vitest-browser 0.0.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 (69) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +21 -0
  3. package/README.md +4 -0
  4. package/dist/VitestBrowserWorld.cjs +179 -0
  5. package/dist/VitestBrowserWorld.cjs.map +1 -0
  6. package/dist/VitestBrowserWorld.d.ts +103 -0
  7. package/dist/VitestBrowserWorld.mjs +176 -0
  8. package/dist/VitestBrowserWorld.mjs.map +1 -0
  9. package/dist/actions.steps.cjs +157 -0
  10. package/dist/actions.steps.cjs.map +1 -0
  11. package/dist/actions.steps.d.ts +1 -0
  12. package/dist/actions.steps.mjs +155 -0
  13. package/dist/actions.steps.mjs.map +1 -0
  14. package/dist/frameworks/ReactBrowserWorld.cjs +38 -0
  15. package/dist/frameworks/ReactBrowserWorld.cjs.map +1 -0
  16. package/dist/frameworks/ReactBrowserWorld.d.ts +10 -0
  17. package/dist/frameworks/ReactBrowserWorld.mjs +36 -0
  18. package/dist/frameworks/ReactBrowserWorld.mjs.map +1 -0
  19. package/dist/frameworks/SvelteBrowserWorld.cjs +17 -0
  20. package/dist/frameworks/SvelteBrowserWorld.cjs.map +1 -0
  21. package/dist/frameworks/SvelteBrowserWorld.d.ts +9 -0
  22. package/dist/frameworks/SvelteBrowserWorld.mjs +15 -0
  23. package/dist/frameworks/SvelteBrowserWorld.mjs.map +1 -0
  24. package/dist/frameworks/VueBrowserWorld.cjs +25 -0
  25. package/dist/frameworks/VueBrowserWorld.cjs.map +1 -0
  26. package/dist/frameworks/VueBrowserWorld.d.ts +10 -0
  27. package/dist/frameworks/VueBrowserWorld.mjs +23 -0
  28. package/dist/frameworks/VueBrowserWorld.mjs.map +1 -0
  29. package/dist/frameworks/react.cjs +11 -0
  30. package/dist/frameworks/react.cjs.map +1 -0
  31. package/dist/frameworks/react.d.ts +1 -0
  32. package/dist/frameworks/react.mjs +9 -0
  33. package/dist/frameworks/react.mjs.map +1 -0
  34. package/dist/frameworks/svelte.cjs +10 -0
  35. package/dist/frameworks/svelte.cjs.map +1 -0
  36. package/dist/frameworks/svelte.d.ts +1 -0
  37. package/dist/frameworks/svelte.mjs +8 -0
  38. package/dist/frameworks/svelte.mjs.map +1 -0
  39. package/dist/frameworks/vue.cjs +10 -0
  40. package/dist/frameworks/vue.cjs.map +1 -0
  41. package/dist/frameworks/vue.d.ts +1 -0
  42. package/dist/frameworks/vue.mjs +8 -0
  43. package/dist/frameworks/vue.mjs.map +1 -0
  44. package/dist/outcomes.steps.cjs +186 -0
  45. package/dist/outcomes.steps.cjs.map +1 -0
  46. package/dist/outcomes.steps.d.ts +1 -0
  47. package/dist/outcomes.steps.mjs +184 -0
  48. package/dist/outcomes.steps.mjs.map +1 -0
  49. package/package.json +103 -0
  50. package/rollup.config.js +58 -0
  51. package/src/VitestBrowserWorld.ts +205 -0
  52. package/src/actions.steps.ts +169 -0
  53. package/src/frameworks/ReactBrowserWorld.ts +41 -0
  54. package/src/frameworks/SvelteBrowserWorld.ts +15 -0
  55. package/src/frameworks/VueBrowserWorld.ts +23 -0
  56. package/src/frameworks/react.ts +4 -0
  57. package/src/frameworks/svelte.ts +4 -0
  58. package/src/frameworks/vue.ts +4 -0
  59. package/src/outcomes.steps.ts +190 -0
  60. package/tests/react/Hello.tsx +23 -0
  61. package/tests/react/react.feature +15 -0
  62. package/tests/svelte/Hello.svelte +31 -0
  63. package/tests/svelte/svelte.feature +16 -0
  64. package/tests/vue/Hello.vue +31 -0
  65. package/tests/vue/vue.feature +16 -0
  66. package/tsconfig.json +17 -0
  67. package/vite.config.ts +8 -0
  68. package/vitest.workspace.ts +95 -0
  69. package/world.ts +7 -0
@@ -0,0 +1,23 @@
1
+ import React, { useState } from 'react'
2
+
3
+ export interface HelloProps {
4
+ name?: string
5
+ }
6
+
7
+ export function Hello({ name = 'world' }: HelloProps) {
8
+ const [currentName, setCurrentName] = useState(name)
9
+
10
+ return (
11
+ <div>
12
+ <h1>Hello {currentName}!</h1>
13
+ <label>
14
+ <span>Name</span>
15
+ <input
16
+ type="text"
17
+ value={currentName}
18
+ onChange={e => setCurrentName(e.target.value)}
19
+ />
20
+ </label>
21
+ </div>
22
+ )
23
+ }
@@ -0,0 +1,15 @@
1
+ Feature: react__hello
2
+
3
+ Scenario: Initial rendering
4
+ Given I render "Hello.tsx"
5
+ Then I should see "Hello world!"
6
+
7
+ Scenario: Render with properties
8
+ Given I render "Hello.tsx" with the following properties:
9
+ | name | property |
10
+ Then I should see "Hello property!"
11
+
12
+ Scenario: Name is changed reactively
13
+ Given I render "Hello.tsx"
14
+ When for "Name" I enter "reactive variable"
15
+ Then I should see "Hello reactive variable!"
@@ -0,0 +1,31 @@
1
+ <script lang="ts">
2
+
3
+ let {
4
+ name = 'world',
5
+ tag = 'h1',
6
+ }:{
7
+ name?:string
8
+ tag?:string
9
+ } = $props()
10
+
11
+ </script>
12
+
13
+ <div>
14
+ <svelte:element this={tag}>Hello {name}!</svelte:element>
15
+ <label>
16
+ <span>Name</span>
17
+ <input type="text" bind:value={name} />
18
+ </label>
19
+ </div>
20
+
21
+ <style>
22
+ div {
23
+ width: 400px;
24
+ margin: 2em auto;
25
+ padding: 1em;
26
+ }
27
+ label>span {
28
+ display: inline-block;
29
+ width: 100px;
30
+ }
31
+ </style>
@@ -0,0 +1,16 @@
1
+ Feature: svelte__hello
2
+
3
+ Scenario: Initial rendering
4
+ Given I render "Hello.svelte"
5
+ Then I should see "Hello world!"
6
+
7
+ @skip-ci
8
+ Scenario: Name is changed reactively
9
+ Given I render "Hello.svelte"
10
+ When for "Name" I enter "reactive variable"
11
+ Then I should see "Hello reactive variable!"
12
+
13
+ Scenario: Render with properties
14
+ Given I render "Hello.svelte" with the following properties:
15
+ | name | property |
16
+ Then I should see "Hello property!"
@@ -0,0 +1,31 @@
1
+ <template>
2
+ <div>
3
+ <h1>Hello {{ nameValue }}!</h1>
4
+ <label>
5
+ <span>Name</span>
6
+ <input type="text" v-model="nameValue" />
7
+ </label>
8
+ </div>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import { ref } from 'vue'
13
+
14
+ const props = defineProps<{
15
+ name?: string
16
+ }>()
17
+
18
+ const nameValue = ref(props.name ?? 'world')
19
+ </script>
20
+
21
+ <style>
22
+ div {
23
+ width: 400px;
24
+ margin: 2em auto;
25
+ padding: 1em;
26
+ }
27
+ label > span {
28
+ display: inline-block;
29
+ width: 100px;
30
+ }
31
+ </style>
@@ -0,0 +1,16 @@
1
+ Feature: vue__hello
2
+
3
+ Scenario: Initial rendering
4
+ Given I render "Hello.vue"
5
+ Then I should see "Hello world!"
6
+
7
+ Scenario: Render with properties
8
+ Given I render "Hello.vue" with the following properties:
9
+ | name | property |
10
+ Then I should see "Hello property!"
11
+
12
+ @skip-ci
13
+ Scenario: Name is changed reactively
14
+ Given I render "Hello.vue"
15
+ When for "Name" I enter "reactive variable"
16
+ Then I should see "Hello reactive variable!"
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "moduleResolution": "node",
6
+ "esModuleInterop": true,
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "outDir": "./dist",
11
+ "rootDir": "./src",
12
+ "declaration": true,
13
+ "sourceMap": true
14
+ },
15
+ "include": ["src/**/*"],
16
+ "exclude": ["node_modules", "dist"]
17
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,8 @@
1
+ import quickpickle from "quickpickle";
2
+
3
+ export default {
4
+ plugins: [quickpickle()],
5
+ optimizeDeps: {
6
+ exclude: ['unicorn-magic'],
7
+ },
8
+ }
@@ -0,0 +1,95 @@
1
+ import { svelte } from '@sveltejs/vite-plugin-svelte';
2
+ import react from '@vitejs/plugin-react';
3
+ import vue from '@vitejs/plugin-vue';
4
+ import path from 'path'
5
+
6
+ const showBrowser = process.env.SHOW_BROWSER ? true : false;
7
+
8
+ export default [
9
+ {
10
+ name: 'svelte',
11
+ extends: `vite.config.ts`,
12
+ plugins: [svelte()],
13
+ optimizeDeps: {
14
+ include: [
15
+ 'vue',
16
+ 'react',
17
+ 'svelte',
18
+ ],
19
+ },
20
+ test: {
21
+ name: 'svelte',
22
+ include: [ `tests/svelte/*.feature` ],
23
+ setupFiles: [ `src/frameworks/svelte.ts`, 'src/actions.steps.ts', 'src/outcomes.steps.ts' ],
24
+ quickpickle: {
25
+ worldConfig: {
26
+ componentDir: 'tests/svelte',
27
+ }
28
+ },
29
+ environment: 'browser',
30
+ browser: {
31
+ enabled: true,
32
+ name: 'chromium',
33
+ provider: 'playwright',
34
+ ui: showBrowser,
35
+ headless: !showBrowser,
36
+ instances: [
37
+ { browser:'chromium' },
38
+ ]
39
+ }
40
+ }
41
+ },
42
+ {
43
+ name: 'react',
44
+ extends: 'vite.config.ts',
45
+ plugins: [react()],
46
+ test: {
47
+ name: 'react',
48
+ include: [ 'tests/react/*.feature' ],
49
+ setupFiles: [ 'src/frameworks/react.ts', 'src/actions.steps.ts', 'src/outcomes.steps.ts' ],
50
+ quickpickle: {
51
+ worldConfig: {
52
+ componentDir: 'tests/react',
53
+ }
54
+ },
55
+ environment: 'browser',
56
+ browser: {
57
+ enabled: true,
58
+ name: 'chromium',
59
+ provider: 'playwright',
60
+ ui: showBrowser,
61
+ headless: !showBrowser,
62
+ instances: [
63
+ { browser:'chromium' },
64
+ ]
65
+ }
66
+ }
67
+ },
68
+ {
69
+ name: 'vue',
70
+ extends: 'vite.config.ts',
71
+ plugins: [vue()],
72
+ test: {
73
+ name: 'vue',
74
+ include: [ 'tests/vue/*.feature' ],
75
+ setupFiles: [ 'src/frameworks/vue.ts', 'src/actions.steps.ts', 'src/outcomes.steps.ts' ],
76
+ quickpickle: {
77
+ worldConfig: {
78
+ componentDir: 'tests/vue',
79
+ }
80
+ },
81
+ environment: 'browser',
82
+ browser: {
83
+ enabled: true,
84
+ name: 'chromium',
85
+ provider: 'playwright',
86
+ ui: showBrowser,
87
+ headless: !showBrowser,
88
+ instances: [
89
+ { browser:'chromium' },
90
+ ]
91
+ }
92
+ }
93
+ }
94
+ ]
95
+
package/world.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { setWorldConstructor } from "quickpickle";
2
+ import { BrowserWorld } from "./BrowserWorld";
3
+
4
+
5
+ setWorldConstructor(VitestBrowserWorld);
6
+
7
+ export { VitestBrowserWorld };