@specwright/plugin 0.1.0
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.
- package/.claude_README.md +276 -0
- package/.claude_memory_MEMORY.md +11 -0
- package/.gitignore.snippet +21 -0
- package/PLUGIN.md +172 -0
- package/README-TESTING.md +227 -0
- package/cli.js +53 -0
- package/e2e-tests/.env.testing +29 -0
- package/e2e-tests/data/authenticationData.js +76 -0
- package/e2e-tests/data/testConfig.js +39 -0
- package/e2e-tests/features/playwright-bdd/@Modules/.gitkeep +0 -0
- package/e2e-tests/features/playwright-bdd/@Modules/@Authentication/authentication.feature +64 -0
- package/e2e-tests/features/playwright-bdd/@Modules/@Authentication/steps.js +27 -0
- package/e2e-tests/features/playwright-bdd/@Workflows/.gitkeep +0 -0
- package/e2e-tests/features/playwright-bdd/shared/auth.steps.js +74 -0
- package/e2e-tests/features/playwright-bdd/shared/common.steps.js +52 -0
- package/e2e-tests/features/playwright-bdd/shared/global-hooks.js +44 -0
- package/e2e-tests/features/playwright-bdd/shared/navigation.steps.js +47 -0
- package/e2e-tests/instructions.example.js +110 -0
- package/e2e-tests/instructions.js +9 -0
- package/e2e-tests/playwright/auth-storage/.auth/.gitkeep +0 -0
- package/e2e-tests/playwright/auth.setup.js +74 -0
- package/e2e-tests/playwright/fixtures.js +264 -0
- package/e2e-tests/playwright/generated/.gitkeep +0 -0
- package/e2e-tests/playwright/global.setup.js +49 -0
- package/e2e-tests/playwright/global.teardown.js +23 -0
- package/e2e-tests/playwright/test-data/.gitkeep +0 -0
- package/e2e-tests/utils/stepHelpers.js +404 -0
- package/e2e-tests/utils/testDataGenerator.js +38 -0
- package/install.sh +148 -0
- package/package.json +39 -0
- package/package.json.snippet +27 -0
- package/playwright.config.ts +143 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { defineConfig, devices } from '@playwright/test';
|
|
2
|
+
import { defineBddConfig, cucumberReporter } from 'playwright-bdd';
|
|
3
|
+
import dotenv from 'dotenv';
|
|
4
|
+
|
|
5
|
+
// Load environment variables
|
|
6
|
+
dotenv.config();
|
|
7
|
+
|
|
8
|
+
// Chrome arguments: use CHROME_ARGS env var (comma-separated) or sensible defaults
|
|
9
|
+
const chromeArgs = process.env.CHROME_ARGS
|
|
10
|
+
? process.env.CHROME_ARGS.split(',')
|
|
11
|
+
.map((a) => a.trim())
|
|
12
|
+
.filter(Boolean)
|
|
13
|
+
: ['--no-sandbox', '--disable-dev-shm-usage'];
|
|
14
|
+
|
|
15
|
+
// Shared launch options
|
|
16
|
+
const defaultLaunchOptions = {
|
|
17
|
+
executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH || undefined,
|
|
18
|
+
args: chromeArgs,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Define BDD configuration
|
|
22
|
+
const testDir = defineBddConfig({
|
|
23
|
+
features: 'e2e-tests/features/playwright-bdd/**/*.feature',
|
|
24
|
+
steps: [
|
|
25
|
+
'e2e-tests/features/playwright-bdd/**/*.{js,ts}',
|
|
26
|
+
'e2e-tests/features/playwright-bdd/shared/*.{js,ts}',
|
|
27
|
+
'e2e-tests/playwright/fixtures.js',
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @see https://playwright.dev/docs/test-configuration
|
|
33
|
+
*/
|
|
34
|
+
export default defineConfig({
|
|
35
|
+
testDir,
|
|
36
|
+
/* Global setup - runs once before all test projects */
|
|
37
|
+
globalSetup: './e2e-tests/playwright/global.setup.js',
|
|
38
|
+
/* Global teardown - runs once after all test projects complete */
|
|
39
|
+
globalTeardown: './e2e-tests/playwright/global.teardown.js',
|
|
40
|
+
/* Default: run scenarios in parallel. Use @serial-execution tag to opt out. */
|
|
41
|
+
fullyParallel: true,
|
|
42
|
+
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
43
|
+
forbidOnly: !!process.env.CI,
|
|
44
|
+
/* Retry on CI only */
|
|
45
|
+
retries: process.env.CI ? 2 : 0,
|
|
46
|
+
timeout: parseInt(process.env.TEST_TIMEOUT || '90000'),
|
|
47
|
+
/* Workers */
|
|
48
|
+
workers: process.env.CI ? 4 : 5,
|
|
49
|
+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
50
|
+
reporter: [
|
|
51
|
+
['json', { outputFile: 'reports/json/results.json' }] as const,
|
|
52
|
+
cucumberReporter('json', { outputFile: 'reports/cucumber-bdd/report.json' }),
|
|
53
|
+
// Console output: "line" on CI, "list" locally
|
|
54
|
+
...(process.env.CI ? [['line'] as const] : [['list'] as const]),
|
|
55
|
+
// HTML reporter: always locally, on CI only when GENERATE_REPORTS is set
|
|
56
|
+
...(!process.env.CI || process.env.GENERATE_REPORTS
|
|
57
|
+
? [['html', { outputFolder: process.env.PLAYWRIGHT_REPORT_DIR || 'reports/playwright' }] as const]
|
|
58
|
+
: []),
|
|
59
|
+
],
|
|
60
|
+
/* Shared settings for all the projects below. */
|
|
61
|
+
use: {
|
|
62
|
+
/* Base URL to use in actions like `await page.goto('/')`. */
|
|
63
|
+
baseURL: process.env.BASE_URL || 'http://localhost:5173',
|
|
64
|
+
|
|
65
|
+
/* Configure headless mode based on environment variable */
|
|
66
|
+
headless: process.env.HEADLESS !== 'false',
|
|
67
|
+
|
|
68
|
+
/* Collect trace when retrying the failed test. */
|
|
69
|
+
trace: process.env.ENABLE_TRACING === 'true' ? 'on-first-retry' : 'off',
|
|
70
|
+
|
|
71
|
+
/* Take screenshot on failure */
|
|
72
|
+
screenshot: process.env.ENABLE_SCREENSHOTS === 'true' ? 'only-on-failure' : 'off',
|
|
73
|
+
|
|
74
|
+
/* Record video on failure */
|
|
75
|
+
video: process.env.ENABLE_VIDEO_RECORDING === 'true' ? 'retain-on-failure' : 'off',
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
/* Configure projects */
|
|
79
|
+
projects: [
|
|
80
|
+
// Setup project - creates authentication state for other projects
|
|
81
|
+
{
|
|
82
|
+
name: 'setup',
|
|
83
|
+
testDir: './e2e-tests/playwright',
|
|
84
|
+
testMatch: '**/auth.setup.js',
|
|
85
|
+
use: {
|
|
86
|
+
...devices['Desktop Chrome'],
|
|
87
|
+
launchOptions: defaultLaunchOptions,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
// Authentication tests - run with clean state (no dependencies, no storageState)
|
|
92
|
+
{
|
|
93
|
+
name: 'auth-tests',
|
|
94
|
+
testMatch: '**/@Authentication/*.spec.js',
|
|
95
|
+
use: {
|
|
96
|
+
...devices['Desktop Chrome'],
|
|
97
|
+
launchOptions: defaultLaunchOptions,
|
|
98
|
+
// Clean state for testing login/logout functionality
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
// Serial execution — features tagged @serial-execution run with 1 worker.
|
|
103
|
+
// Browser page is reused across scenarios within the same feature file.
|
|
104
|
+
{
|
|
105
|
+
name: 'serial-execution',
|
|
106
|
+
testMatch: '**/*.spec.js',
|
|
107
|
+
testIgnore: '**/@Authentication/*.spec.js',
|
|
108
|
+
grep: /@serial-execution/,
|
|
109
|
+
fullyParallel: false,
|
|
110
|
+
workers: 1,
|
|
111
|
+
use: {
|
|
112
|
+
...devices['Desktop Chrome'],
|
|
113
|
+
launchOptions: defaultLaunchOptions,
|
|
114
|
+
storageState: 'e2e-tests/playwright/auth-storage/.auth/user.json',
|
|
115
|
+
},
|
|
116
|
+
dependencies: ['setup'],
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
// Main BDD tests — everything not serial or auth. Runs parallel by default.
|
|
120
|
+
{
|
|
121
|
+
name: 'main-e2e',
|
|
122
|
+
testMatch: '**/*.spec.js',
|
|
123
|
+
testIgnore: '**/@Authentication/*.spec.js',
|
|
124
|
+
grepInvert: /@serial-execution/,
|
|
125
|
+
use: {
|
|
126
|
+
...devices['Desktop Chrome'],
|
|
127
|
+
launchOptions: defaultLaunchOptions,
|
|
128
|
+
storageState: 'e2e-tests/playwright/auth-storage/.auth/user.json',
|
|
129
|
+
},
|
|
130
|
+
dependencies: ['setup'],
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
|
|
134
|
+
/* Run your local dev server before starting the tests */
|
|
135
|
+
webServer: process.env.BASE_URL?.startsWith('http://localhost')
|
|
136
|
+
? {
|
|
137
|
+
command: 'pnpm dev',
|
|
138
|
+
url: process.env.BASE_URL || 'http://localhost:5173',
|
|
139
|
+
reuseExistingServer: true,
|
|
140
|
+
timeout: 120 * 1000,
|
|
141
|
+
}
|
|
142
|
+
: undefined,
|
|
143
|
+
});
|