diff --git a/packages/browser/README.md b/packages/browser/README.md new file mode 100644 index 0000000..9bed41d --- /dev/null +++ b/packages/browser/README.md @@ -0,0 +1,4 @@ +# Vitest: Browser Mode + +This is the library for testing quickpickle using Vitest with browser mode. + diff --git a/packages/browser/package.json b/packages/browser/package.json new file mode 100644 index 0000000..724afc0 --- /dev/null +++ b/packages/browser/package.json @@ -0,0 +1,18 @@ +{ + "name": "browser", + "version": "0.0.1", + "description": "This is the library for testing quickpickle with Vitest in browser mode", + "private": true, + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@vitest/browser": "^2.1.2", + "quickpickle": "^1.1.2", + "vitest": "^2.1.2" + } +} diff --git a/packages/browser/tests/browser.feature b/packages/browser/tests/browser.feature new file mode 100644 index 0000000..3d8bb6a --- /dev/null +++ b/packages/browser/tests/browser.feature @@ -0,0 +1,5 @@ +Feature: Vitest in "browser" mode + + Scenario: Can we run Vitest in "browser" mode? + Given I go to "./browser.test.html" + Then I should see "Acid3" \ No newline at end of file diff --git a/packages/browser/tests/browser.steps.ts b/packages/browser/tests/browser.steps.ts new file mode 100644 index 0000000..b26aa53 --- /dev/null +++ b/packages/browser/tests/browser.steps.ts @@ -0,0 +1,12 @@ +import { Given, When, Then, DataTable } from "quickpickle"; +import { QuickPickleWorld } from "../../main/src/world"; + +import { page, commands, server } from '@vitest/browser/context' + +When('I go to {string}', async (world:QuickPickleWorld,url) => { + await commands.readFile(url) +}) + +Then('I should see {string}', async (world:QuickPickleWorld,text) => { + await page.getByText(text) +}) \ No newline at end of file diff --git a/packages/browser/tests/browser.test.html b/packages/browser/tests/browser.test.html new file mode 100644 index 0000000..e5ecc16 --- /dev/null +++ b/packages/browser/tests/browser.test.html @@ -0,0 +1,31 @@ + + + + + + + Browser Test Page + + +

Browser Test Page

+ +

This is a simple test page for browser functionality.

+ +

Test Form

+
+ +

+ + +

+ +
+

+ + +
+ +

Additional Information

+

This page is used for testing various browser functionalities and interactions.

+ + diff --git a/packages/browser/vitest.workspace.ts b/packages/browser/vitest.workspace.ts new file mode 100644 index 0000000..73bd3ac --- /dev/null +++ b/packages/browser/vitest.workspace.ts @@ -0,0 +1,13 @@ +export default [{ + test: { + include: [ 'tests/*.feature' ], + setupFiles: [ 'tests/browser.steps.ts' ], + environment: 'jsdom', + browser: { + enabled: true, + name: 'chromium', + provider: 'playwright', + ui: true, + } + } +}] diff --git a/packages/main/vitest.workspace.ts b/packages/main/vitest.workspace.ts index e86526f..5bf8bf1 100644 --- a/packages/main/vitest.workspace.ts +++ b/packages/main/vitest.workspace.ts @@ -12,5 +12,5 @@ export default defineWorkspace([ test: { include : [ './tests/*.test.ts' ], } - } + }, ]) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 07164b2..577a9f8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,6 +19,18 @@ importers: specifier: ^2.1.2 version: 2.1.2(@types/node@22.7.4)(@vitest/browser@2.1.2)(jsdom@25.0.1)(msw@2.4.9(typescript@5.6.2))(terser@5.34.1) + packages/browser: + devDependencies: + '@vitest/browser': + specifier: ^2.1.2 + version: 2.1.2(@vitest/spy@2.1.2)(playwright@1.48.0)(typescript@5.6.2)(vite@5.4.8(@types/node@22.7.4)(terser@5.34.1))(vitest@2.1.2) + quickpickle: + specifier: ^1.1.2 + version: 1.1.2 + vitest: + specifier: ^2.1.2 + version: 2.1.2(@types/node@22.7.4)(@vitest/browser@2.1.2)(jsdom@25.0.1)(msw@2.4.9(typescript@5.6.2))(terser@5.34.1) + packages/main: dependencies: '@cucumber/cucumber': @@ -1718,6 +1730,9 @@ packages: queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + quickpickle@1.1.2: + resolution: {integrity: sha512-S5lqcMq+6vUhwdNyBDg2MEjT7OY8G1Xd5iN7PYLiDV/t5OMgTp4Jo8YvnFvDIFehZCo8hn0bVo30jStqPRLe5A==} + randombytes@2.1.0: resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} @@ -2520,7 +2535,7 @@ snapshots: '@cucumber/ci-environment': 10.0.1 '@cucumber/cucumber-expressions': 17.1.0 '@cucumber/gherkin': 28.0.0 - '@cucumber/gherkin-streams': 5.0.1(@cucumber/gherkin@28.0.0)(@cucumber/message-streams@4.0.1(@cucumber/messages@22.0.0))(@cucumber/messages@24.1.0) + '@cucumber/gherkin-streams': 5.0.1(@cucumber/gherkin@28.0.0)(@cucumber/message-streams@4.0.1(@cucumber/messages@24.1.0))(@cucumber/messages@24.1.0) '@cucumber/gherkin-utils': 9.0.0 '@cucumber/html-formatter': 21.6.0(@cucumber/messages@24.1.0) '@cucumber/message-streams': 4.0.1(@cucumber/messages@24.1.0) @@ -2560,7 +2575,7 @@ snapshots: yaml: 2.5.1 yup: 1.2.0 - '@cucumber/gherkin-streams@5.0.1(@cucumber/gherkin@28.0.0)(@cucumber/message-streams@4.0.1(@cucumber/messages@22.0.0))(@cucumber/messages@24.1.0)': + '@cucumber/gherkin-streams@5.0.1(@cucumber/gherkin@28.0.0)(@cucumber/message-streams@4.0.1(@cucumber/messages@24.1.0))(@cucumber/messages@24.1.0)': dependencies: '@cucumber/gherkin': 28.0.0 '@cucumber/message-streams': 4.0.1(@cucumber/messages@24.1.0) @@ -3049,7 +3064,6 @@ snapshots: - typescript - utf-8-validate - vite - optional: true '@vitest/expect@2.1.2': dependencies: @@ -3943,6 +3957,16 @@ snapshots: queue-microtask@1.2.3: {} + quickpickle@1.1.2: + dependencies: + '@cucumber/cucumber': 11.0.1 + '@cucumber/cucumber-expressions': 16.1.2 + '@cucumber/gherkin': 29.0.0 + '@cucumber/messages': 22.0.0 + '@cucumber/tag-expressions': 6.1.0 + fast-glob: 3.3.2 + lodash-es: 4.17.21 + randombytes@2.1.0: dependencies: safe-buffer: 5.2.1