-
Notifications
You must be signed in to change notification settings - Fork 0
ci: add browser environment test suite #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5582842
feat: add browser environment test suite using jest-environment-jsdom
DecimalTurn 0174bb3
style: fix jest.config.mjs formatting - one property per line
DecimalTurn 5de8e6a
style: fix jest.config.browser.mjs formatting - one property per line
DecimalTurn ae6249e
feat: add Playwright smoke tests for real browser environment
DecimalTurn 4b8de20
refactor: replace jsdom tests with Playwright for real browser testing
DecimalTurn f5eed4b
chore: add Playwright output dirs to .gitignore
DecimalTurn d020c96
chore: update lockfile after removing jest-environment-jsdom
DecimalTurn da1e7a1
test: add test:playwright into test:all
DecimalTurn 560ea82
fix(tsconfig): include TypeScript files in the root directory
DecimalTurn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,6 @@ toml-patch.code-workspace | |
| *.cpuprofile | ||
| benchmark-*.md | ||
|
|
||
|
|
||
| test-results/ | ||
| playwright-report/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
| import { readFileSync } from 'fs'; | ||
| import { join } from 'path'; | ||
|
|
||
| const bundle = readFileSync(join(process.cwd(), 'dist/toml-patch.js'), 'utf-8'); | ||
|
|
||
| // Load the bundle into the page via a blob URL so it runs in a real browser | ||
| // module context — no Node.js APIs available. | ||
| async function loadTOML(page: import('@playwright/test').Page) { | ||
| await page.goto('about:blank'); | ||
| await page.evaluate(async (src: string) => { | ||
| const blob = new Blob([src], { type: 'application/javascript' }); | ||
| const url = URL.createObjectURL(blob); | ||
| (window as any).__TOML__ = await import(url); | ||
| URL.revokeObjectURL(url); | ||
| }, bundle); | ||
| } | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| await loadTOML(page); | ||
| }); | ||
|
|
||
| test('parse should work in real browser', async ({ page }) => { | ||
| const result = await page.evaluate(() => | ||
| (window as any).__TOML__.parse('key = "hello"') | ||
| ); | ||
| expect(result).toEqual({ key: 'hello' }); | ||
| }); | ||
|
|
||
| test('stringify should work in real browser', async ({ page }) => { | ||
| const result = await page.evaluate(() => | ||
| (window as any).__TOML__.stringify({ key: 'hello' }) | ||
| ); | ||
| expect(result).toBe('key = "hello"\n'); | ||
| }); | ||
|
|
||
| test('patch should work in real browser', async ({ page }) => { | ||
| const result = await page.evaluate(() => | ||
| (window as any).__TOML__.patch('key = "hello"\n', { key: 'world' }) | ||
| ); | ||
| expect(result).toBe('key = "world"\n'); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { defineConfig } from '@playwright/test'; | ||
|
|
||
| export default defineConfig({ | ||
| testDir: './browser-tests', | ||
| projects: [ | ||
| { name: 'chromium', use: { browserName: 'chromium' } }, | ||
DecimalTurn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ], | ||
| }); | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.