create-pw-core 1.3.0 → 1.3.1
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/dist/index.js +24 -13
- package/dist/templates/package.json +3 -3
- package/dist/templates/playwright.config.ts +5 -5
- package/dist/templates/src/pages/registry.ts +1 -1
- package/dist/templates/src/tests/parallel.test.ts +1 -1
- package/dist/templates/src/tests/serial.test.ts +28 -38
- package/dist/templates/tsconfig.json +6 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38,6 +38,9 @@ const fs = __importStar(require("fs"));
|
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const child_process_1 = require("child_process");
|
|
40
40
|
const readline = __importStar(require("readline"));
|
|
41
|
+
function readPackageJson(filePath) {
|
|
42
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
43
|
+
}
|
|
41
44
|
const rl = readline.createInterface({
|
|
42
45
|
input: process.stdin,
|
|
43
46
|
output: process.stdout
|
|
@@ -106,32 +109,24 @@ function copyRecursiveSync(src, dest) {
|
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
async function main() {
|
|
109
|
-
console.log('\n\x1b[35m============================================\x1b[0m');
|
|
110
|
-
console.log('\x1b[35m Initializing pw-core Test Suite \x1b[0m');
|
|
111
|
-
console.log('\x1b[35m============================================\n\x1b[0m');
|
|
112
|
-
const projectPathInput = await question('Project path (default: current directory): ');
|
|
113
|
-
const targetDir = projectPathInput.trim() ? path.resolve(process.cwd(), projectPathInput.trim()) : process.cwd();
|
|
114
|
-
if (!fs.existsSync(targetDir)) {
|
|
115
|
-
fs.mkdirSync(targetDir, { recursive: true });
|
|
116
|
-
}
|
|
117
112
|
// Detect paths and find templates
|
|
118
113
|
const devRepoPath = path.resolve(__dirname, '../..');
|
|
119
114
|
const devRepoPkgPath = path.join(devRepoPath, 'package.json');
|
|
120
115
|
let isDevRepo = false;
|
|
121
116
|
if (fs.existsSync(devRepoPkgPath)) {
|
|
122
117
|
try {
|
|
123
|
-
const devRepoPkg =
|
|
118
|
+
const devRepoPkg = readPackageJson(devRepoPkgPath);
|
|
124
119
|
if (devRepoPkg.name === 'pw-core') {
|
|
125
120
|
isDevRepo = true;
|
|
126
121
|
}
|
|
127
122
|
}
|
|
128
123
|
catch (e) { }
|
|
129
124
|
}
|
|
130
|
-
// Check for latest version on registry to bypass npx cache issues
|
|
125
|
+
// Check for latest version on registry BEFORE prompting to bypass npx cache issues
|
|
131
126
|
const pkgJsonPath = path.join(__dirname, '../package.json');
|
|
132
127
|
if (fs.existsSync(pkgJsonPath) && !isDevRepo) {
|
|
133
128
|
try {
|
|
134
|
-
const pkg =
|
|
129
|
+
const pkg = readPackageJson(pkgJsonPath);
|
|
135
130
|
const currentVersion = pkg.version;
|
|
136
131
|
const latestVersion = (0, child_process_1.execSync)('npm view create-pw-core version', {
|
|
137
132
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
@@ -160,6 +155,22 @@ async function main() {
|
|
|
160
155
|
// Offline or network error: continue with the cached version
|
|
161
156
|
}
|
|
162
157
|
}
|
|
158
|
+
console.log('\n\x1b[35m============================================\x1b[0m');
|
|
159
|
+
console.log('\x1b[35m Initializing pw-core Test Suite \x1b[0m');
|
|
160
|
+
console.log('\x1b[35m============================================\n\x1b[0m');
|
|
161
|
+
const cliArgs = process.argv.slice(2).filter((arg) => !arg.startsWith('-'));
|
|
162
|
+
let targetDir = '';
|
|
163
|
+
if (cliArgs.length > 0 && cliArgs[0]) {
|
|
164
|
+
targetDir = path.resolve(process.cwd(), cliArgs[0].trim());
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const projectPathInput = await question('Project path (default: current directory): ');
|
|
168
|
+
const trimmed = projectPathInput.trim();
|
|
169
|
+
targetDir = trimmed ? path.resolve(process.cwd(), trimmed) : process.cwd();
|
|
170
|
+
}
|
|
171
|
+
if (!fs.existsSync(targetDir)) {
|
|
172
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
173
|
+
}
|
|
163
174
|
let templatesDir = path.join(__dirname, 'templates');
|
|
164
175
|
let templatePkgPath = path.join(templatesDir, 'package.json');
|
|
165
176
|
if (isDevRepo) {
|
|
@@ -169,7 +180,7 @@ async function main() {
|
|
|
169
180
|
let templatePkg = {};
|
|
170
181
|
if (fs.existsSync(templatePkgPath)) {
|
|
171
182
|
try {
|
|
172
|
-
templatePkg =
|
|
183
|
+
templatePkg = readPackageJson(templatePkgPath);
|
|
173
184
|
}
|
|
174
185
|
catch (e) {
|
|
175
186
|
console.warn(`Warning: Could not parse template package.json: ${e}`);
|
|
@@ -203,7 +214,7 @@ async function main() {
|
|
|
203
214
|
console.log('\x1b[32mSuccessfully copied template files.\x1b[0m');
|
|
204
215
|
// Update target package.json with dependencies and scripts
|
|
205
216
|
console.log('\nUpdating package.json...');
|
|
206
|
-
const targetPkg =
|
|
217
|
+
const targetPkg = readPackageJson(packageJsonPath);
|
|
207
218
|
// Merge description, author, license if target has empty or default ones
|
|
208
219
|
if (!targetPkg.description || targetPkg.description === 'pw-core test suite') {
|
|
209
220
|
targetPkg.description = templatePkg.description || 'pw-core test suite';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pw-core-demo",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Demo and example test suite showcasing the usage of pw-core in Playwright.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "playwright test",
|
|
7
7
|
"test:headed": "playwright test --headed",
|
|
8
8
|
"test:report": "playwright show-report",
|
|
9
9
|
"test:ui": "playwright test --ui",
|
|
10
|
-
"codegen": "pw-core",
|
|
10
|
+
"codegen": "npx pw-core codegen",
|
|
11
11
|
"codegen:safe": "npx pw-core codegen --safe",
|
|
12
12
|
"lint": "eslint .",
|
|
13
13
|
"lint:fix": "eslint . --fix"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@types/node": "^20.11.0",
|
|
25
25
|
"dotenv": "^16.4.5",
|
|
26
26
|
"eslint": "^10.6.0",
|
|
27
|
-
"pw-core": "^1.3.
|
|
27
|
+
"pw-core": "^1.3.1",
|
|
28
28
|
"typescript": "^6.0.3",
|
|
29
29
|
"typescript-eslint": "^8.62.1"
|
|
30
30
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineConfig } from '@playwright/test'
|
|
2
|
-
import { env } from 'src/utils/env'
|
|
1
|
+
import { defineConfig } from '@playwright/test'
|
|
2
|
+
import { env } from './src/utils/env'
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
5
|
testDir: './src/tests',
|
|
6
6
|
timeout: 30000,
|
|
7
7
|
expect: {
|
|
8
|
-
timeout: 5000
|
|
8
|
+
timeout: 5000
|
|
9
9
|
},
|
|
10
10
|
reporter: [['html'], ['list']],
|
|
11
11
|
use: {
|
|
@@ -18,7 +18,7 @@ export default defineConfig({
|
|
|
18
18
|
projects: [
|
|
19
19
|
{
|
|
20
20
|
name: 'chrome',
|
|
21
|
-
use: { browserName: 'chromium' }
|
|
21
|
+
use: { browserName: 'chromium' }
|
|
22
22
|
}
|
|
23
23
|
]
|
|
24
|
-
})
|
|
24
|
+
})
|
|
@@ -1,49 +1,39 @@
|
|
|
1
|
-
import { registry as test } from
|
|
1
|
+
import { registry as test } from '@pages/registry'
|
|
2
2
|
|
|
3
3
|
// Serial — all tests run sequentially in one browser, sharing the same worker page
|
|
4
4
|
test.describe.serial('Playground Serial Suite', () => {
|
|
5
5
|
test.beforeAll(async ({ workerPlayground }) => {
|
|
6
|
-
await workerPlayground.goto()
|
|
6
|
+
await workerPlayground.goto()
|
|
7
7
|
})
|
|
8
8
|
|
|
9
|
-
test(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
test('Navigate to playground and interact with input elements', async ({ workerPlayground }) => {
|
|
10
|
+
await workerPlayground.click('tabTriggerInputs')
|
|
11
|
+
await workerPlayground.fill('playgroundText', 'Serial Input')
|
|
12
|
+
await workerPlayground.fill('playgroundPassword', 'pass123')
|
|
13
|
+
await workerPlayground.fill('playgroundNumber', '99')
|
|
14
|
+
await workerPlayground.fill('playgroundTextarea', 'Worker-scoped textarea content')
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
await workerPlayground.fill('playgroundTextarea', 'Worker-scoped textarea content');
|
|
18
|
-
|
|
19
|
-
await workerPlayground.click('playgroundSwitch');
|
|
20
|
-
await workerPlayground.check('Accept terms');
|
|
21
|
-
}
|
|
22
|
-
);
|
|
16
|
+
await workerPlayground.click('playgroundSwitch')
|
|
17
|
+
await workerPlayground.check('Accept terms')
|
|
18
|
+
})
|
|
23
19
|
|
|
24
|
-
test(
|
|
25
|
-
|
|
26
|
-
async ({ workerPlayground }) => {
|
|
27
|
-
await workerPlayground.click('tabTriggerButtons');
|
|
20
|
+
test('Switch to buttons tab and interact with button variants', async ({ workerPlayground }) => {
|
|
21
|
+
await workerPlayground.click('tabTriggerButtons')
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
await workerPlayground.click('btnVariantDefault')
|
|
24
|
+
await workerPlayground.click('btnVariantSecondary')
|
|
25
|
+
await workerPlayground.click('btnVariantOutline')
|
|
26
|
+
await workerPlayground.click('btnVariantDestructive')
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
);
|
|
28
|
+
await workerPlayground.click('toggleAlignCenter')
|
|
29
|
+
await workerPlayground.click('toggleAlignRight')
|
|
30
|
+
await workerPlayground.click('toggleAlignLeft')
|
|
31
|
+
})
|
|
39
32
|
|
|
40
|
-
test(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
});
|
|
33
|
+
test('Browse remaining tabs on the shared worker page', async ({ workerPlayground }) => {
|
|
34
|
+
await workerPlayground.click('tabTriggerTables')
|
|
35
|
+
await workerPlayground.click('tabTriggerCharts')
|
|
36
|
+
await workerPlayground.click('tabTriggerOverlays')
|
|
37
|
+
await workerPlayground.click('tabTriggerAdvanced')
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -7,16 +7,18 @@
|
|
|
7
7
|
"skipLibCheck": true,
|
|
8
8
|
"forceConsistentCasingInFileNames": true,
|
|
9
9
|
"noEmit": true,
|
|
10
|
-
"baseUrl": ".",
|
|
11
10
|
"paths": {
|
|
11
|
+
"src/*": [
|
|
12
|
+
"./src/*"
|
|
13
|
+
],
|
|
12
14
|
"@pages/*": [
|
|
13
|
-
"src/pages/*"
|
|
15
|
+
"./src/pages/*"
|
|
14
16
|
],
|
|
15
17
|
"@tests/*": [
|
|
16
|
-
"src/tests/*"
|
|
18
|
+
"./src/tests/*"
|
|
17
19
|
],
|
|
18
20
|
"@utils/*": [
|
|
19
|
-
"src/utils/*"
|
|
21
|
+
"./src/utils/*"
|
|
20
22
|
]
|
|
21
23
|
}
|
|
22
24
|
},
|