-
-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Playwright for components plugin (#262)
* split playwright-ct into its own plugin * export playwright-ct plugin
- Loading branch information
Showing
11 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
6 changes: 6 additions & 0 deletions
6
fixtures/plugins/playwright-ct/node_modules/@playwright/experimental-ct-react/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,9 @@ | ||
{ | ||
"name": "@fixtures/playwright-ct", | ||
"scripts": { | ||
"test-ct": "playwright test -c playwright-ct.config.ts" | ||
}, | ||
"devDependencies": { | ||
"@playwright/experimental-ct-react": "*" | ||
} | ||
} |
This file contains 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,10 @@ | ||
import { defineConfig, devices } from '@playwright/experimental-ct-react'; | ||
|
||
export default defineConfig({ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: devices['Desktop Chrome'], | ||
}, | ||
], | ||
}); |
This file contains 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,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Testing Page</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="./index.tsx"></script> | ||
</body> | ||
</html> |
This file contains 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,2 @@ | ||
// Import styles, initialize component theme here. | ||
// import '../src/common.css'; |
This file contains 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,7 @@ | ||
import { test, expect } from '@playwright/experimental-ct-react'; | ||
|
||
test.describe('stuff', () => { | ||
test('thing', async () => { | ||
expect(null).toMatch(null); | ||
}); | ||
}); |
This file contains 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 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,22 @@ | ||
# Playwright for components | ||
|
||
## Enabled | ||
|
||
This plugin is enabled when any of the following package names and/or regular expressions has a match in `dependencies` | ||
or `devDependencies`: | ||
|
||
- `/^@playwright\/experimental-ct-/` | ||
|
||
## Default configuration | ||
|
||
```json | ||
{ | ||
"playwright-ct": { | ||
"entry": ["playwright-ct.config.{js,ts}", "playwright/index.{js,ts,jsx,tsx}"] | ||
} | ||
} | ||
``` | ||
|
||
Also see [Knip plugins][1] for more information about plugins. | ||
|
||
[1]: https://github.com/webpro/knip/blob/main/README.md#plugins |
This file contains 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,14 @@ | ||
import { hasDependency } from '../../util/plugin.js'; | ||
import type { IsPluginEnabledCallback } from '../../types/plugins.js'; | ||
|
||
// https://playwright.dev/docs/test-components | ||
|
||
export const NAME = 'Playwright for components'; | ||
|
||
/** @public */ | ||
export const ENABLERS = [/^@playwright\/experimental-ct-/]; | ||
|
||
export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS); | ||
|
||
// `TEST_FILE_PATTERNS` in src/constants.ts are already included by default | ||
export const ENTRY_FILE_PATTERNS = ['playwright-ct.config.{js,ts}', 'playwright/index.{js,ts,jsx,tsx}']; |
This file contains 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,23 @@ | ||
import assert from 'node:assert/strict'; | ||
import test from 'node:test'; | ||
import { main } from '../../src/index.js'; | ||
import { resolve } from '../../src/util/path.js'; | ||
import baseArguments from '../helpers/baseArguments.js'; | ||
import baseCounters from '../helpers/baseCounters.js'; | ||
|
||
const cwd = resolve('fixtures/plugins/playwright-ct'); | ||
|
||
test('Find dependencies in Playwright for components configuration', async () => { | ||
const { counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
}); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
devDependencies: 0, | ||
unlisted: 0, | ||
processed: 3, | ||
total: 3, | ||
}); | ||
}); |