simple-playwright-framework 0.0.6 → 0.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-playwright-framework",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "A modular Playwright framework with fixtures, loaders, and demo scaffolding.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  const fs = require("fs");
3
3
  const path = require("path");
4
+ const { execSync } = require("child_process");
4
5
 
5
6
  const cwd = process.cwd();
6
7
  const demoDir = path.join(cwd, "demo-project");
@@ -12,20 +13,52 @@ function writeFileSafe(filePath, content) {
12
13
  console.log(`📄 Created: ${filePath}`);
13
14
  }
14
15
 
16
+ function run(cmd, cwd) {
17
+ console.log(`> ${cmd}`);
18
+ execSync(cmd, { stdio: "inherit", cwd });
19
+ }
20
+
15
21
  // package.json
16
22
  writeFileSafe(path.join(demoDir, "package.json"),
17
23
  JSON.stringify({
18
24
  name: "demo-project",
19
25
  version: "1.0.0",
20
26
  private: true,
21
- scripts: { test: "playwright test" },
27
+ scripts: {
28
+ init: "node ../framework/scripts/init-demo-project.js",
29
+ clean: "rimraf dist tsconfig.tsbuildinfo",
30
+ build: "tsc --build --force",
31
+ test: "playwright test"
32
+ },
22
33
  devDependencies: {
23
34
  "@playwright/test": "^1.58.2",
24
- "simple-playwright-framework": "latest"
35
+ "simple-playwright-framework": "latest",
36
+ "@types/node": "^20.0.0",
37
+ "rimraf": "^5.0.0"
25
38
  }
26
39
  }, null, 2)
27
40
  );
28
41
 
42
+ // tsconfig.json
43
+ writeFileSafe(path.join(demoDir, "tsconfig.json"),
44
+ JSON.stringify({
45
+ compilerOptions: {
46
+ target: "ESNext",
47
+ module: "CommonJS",
48
+ strict: true,
49
+ noImplicitAny: true,
50
+ esModuleInterop: true,
51
+ moduleResolution: "Node",
52
+ resolveJsonModule: true,
53
+ types: ["@playwright/test", "simple-playwright-framework", "node"],
54
+ baseUrl: ".",
55
+ paths: { "@demo-project/*": ["./*"] },
56
+ outDir: "dist"
57
+ },
58
+ include: ["tests/**/*.ts", "global.d.ts"]
59
+ }, null, 2)
60
+ );
61
+
29
62
  // playwright.config.ts
30
63
  writeFileSafe(path.join(demoDir, "playwright.config.ts"), `import { defineConfig } from '@playwright/test';
31
64
  export default defineConfig({ testDir: './tests', reporter: [['html']] });
@@ -106,7 +139,7 @@ test('login with Admin user @smoke', async ({ page, envConfig, td }) => {
106
139
  `);
107
140
 
108
141
  writeFileSafe(path.join(demoDir, "tests/login/login.scenarios.spec.ts"), `import { test, expect, scenarioLoader, initAuthSession } from 'simple-playwright-framework';
109
- import { providerRegistry } from '@project/auth';
142
+ import { providerRegistry } from '@demo-project/auth';
110
143
  const scenarios = scenarioLoader(__filename);
111
144
  test.describe.parallel("Login scenarios", () => {
112
145
  for (const sc of scenarios) {
@@ -124,7 +157,7 @@ test.describe.parallel("Login scenarios", () => {
124
157
  `);
125
158
 
126
159
  writeFileSafe(path.join(demoDir, "tests/login/loginwithauthstorage.spec.ts"), `import { test, expect, initAuthSession } from 'simple-playwright-framework';
127
- import { providerRegistry } from '@project/auth';
160
+ import { providerRegistry } from '@demo-project/auth';
128
161
  test('login with Admin user using Auth Storage', async ({ page, envConfig, td }) => {
129
162
  await page.goto(envConfig.baseUrl);
130
163
  await initAuthSession(page, envConfig.authStorage!, { username: td.users.admin.username, password: td.users.admin.password }, providerRegistry);
@@ -183,4 +216,20 @@ test('reporting example', async ({ testrail }) => {
183
216
  });
184
217
  `);
185
218
 
186
- // README
219
+ // README
220
+ writeFileSafe(path.join(demoDir, "README.md"), `# Demo Project
221
+
222
+ This is a scaffolded Playwright demo project using **simple-playwright-framework**.
223
+ Run \`npm run test\` to execute the sample tests.
224
+ `);
225
+
226
+ // Final step: install deps + build
227
+ try {
228
+ console.log("🚀 Installing dependencies and building demo-project...");
229
+ run("npm install", demoDir);
230
+ run("npm run build", demoDir);
231
+ console.log("✅ Demo project initialized. Ready to run Playwright tests!");
232
+ } catch (err) {
233
+ console.error("❌ Init failed:", err.message);
234
+ process.exit(1);
235
+ }