@zhiweiliu/playwright-generator 1.0.4 → 1.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/README.md CHANGED
@@ -135,7 +135,7 @@ project-root/
135
135
  # AI Model Configuration
136
136
  AI_MODEL=copilot # Options: copilot, claude
137
137
  COPILOT_API_KEY=your_key_here # Required if using Copilot
138
- CLAUDE_API_KEY=your_key_here # Required if using Claude
138
+ CLAUDE_API_KEY=sk-ant-... # Required if using Claude (starts with sk-ant-)
139
139
 
140
140
  # Playwright Configuration
141
141
  BROWSER=chromium # Options: chromium, firefox, webkit
@@ -310,13 +310,14 @@ Workflow file location: `.github/workflows/playwright-tests.yml`
310
310
 
311
311
  **Common Issues**:
312
312
 
313
- | Issue | Solution |
314
- | ----------------------------------- | ------------------------------------------------------------------------------------- |
315
- | `API key not found` | Verify `.env` file exists and `COPILOT_API_KEY` or `CLAUDE_API_KEY` is set |
316
- | `Tests timing out` | Increase `TIMEOUT` in `.env` or use explicit waits in test cases |
317
- | `Generated code doesn't compile` | Review the natural language description for clarity; regenerate with a refined prompt |
318
- | `Tests pass locally but fail in CI` | Check `BASE_URL` environment variable and add debugging with screenshots |
319
- | `Selector not found` | Ensure selectors are unique and reference current UI state |
313
+ | Issue | Solution |
314
+ | ----------------------------------- | --------------------------------------------------------------------------------------------------- |
315
+ | `API key not found` | Verify `.env` file exists and `COPILOT_API_KEY` or `CLAUDE_API_KEY` is set |
316
+ | `Claude API connection failed` | Check `CLAUDE_API_KEY` is valid and account has Claude API access; ensure key starts with `sk-ant-` |
317
+ | `Tests timing out` | Increase `TIMEOUT` in `.env` or use explicit waits in test cases |
318
+ | `Generated code doesn't compile` | Review the natural language description for clarity; regenerate with a refined prompt |
319
+ | `Tests pass locally but fail in CI` | Check `BASE_URL` environment variable and add debugging with screenshots |
320
+ | `Selector not found` | Ensure selectors are unique and reference current UI state |
320
321
 
321
322
  ### GitHub Integration
322
323
 
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ const program = new commander_1.Command();
12
12
  program
13
13
  .name("playwright-generator")
14
14
  .description("Generate Playwright test cases from natural language using LLM")
15
- .version("1.0.0");
15
+ .version("1.0.6");
16
16
  // Init command
17
17
  program
18
18
  .command("init [projectPath]")
@@ -1 +1 @@
1
- {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/llm/claude.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEnE,qBAAa,cAAe,SAAQ,WAAW;IAC7C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAA2C;gBAE9C,MAAM,EAAE,MAAM;IAQpB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IA8BtC,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC;CA4ClE"}
1
+ {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/llm/claude.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEnE,qBAAa,cAAe,SAAQ,WAAW;IAC7C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAA2C;gBAE9C,MAAM,EAAE,MAAM;IAapB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAsCtC,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC;CA8ClE"}
@@ -13,12 +13,15 @@ class ClaudeProvider extends provider_1.LLMProvider {
13
13
  if (!apiKey) {
14
14
  throw new Error("Claude API key is required");
15
15
  }
16
+ if (!apiKey.startsWith("sk-ant-")) {
17
+ throw new Error("Claude API key should start with 'sk-ant-'. Please check your Anthropic API key.");
18
+ }
16
19
  this.apiKey = apiKey;
17
20
  }
18
21
  async validateConnection() {
19
22
  try {
20
23
  const response = await axios_1.default.post(this.baseUrl, {
21
- model: "claude-3-sonnet-20240229",
24
+ model: "claude-3-haiku-20240307",
22
25
  max_tokens: 100,
23
26
  messages: [
24
27
  {
@@ -30,6 +33,7 @@ class ClaudeProvider extends provider_1.LLMProvider {
30
33
  headers: {
31
34
  "x-api-key": this.apiKey,
32
35
  "anthropic-version": "2023-06-01",
36
+ "anthropic-beta": "messages-2023-12-15",
33
37
  "Content-Type": "application/json",
34
38
  },
35
39
  timeout: 5000,
@@ -37,7 +41,12 @@ class ClaudeProvider extends provider_1.LLMProvider {
37
41
  return response.status === 200;
38
42
  }
39
43
  catch (error) {
40
- console.error("Claude connection validation failed:", error);
44
+ if (error.response) {
45
+ console.error(`Claude connection validation failed with status ${error.response.status}:`, error.response.data);
46
+ }
47
+ else {
48
+ console.error("Claude connection validation failed:", error.message);
49
+ }
41
50
  return false;
42
51
  }
43
52
  }
@@ -45,7 +54,7 @@ class ClaudeProvider extends provider_1.LLMProvider {
45
54
  try {
46
55
  const systemPrompt = this.buildPrompt(prompt.testCase);
47
56
  const response = await axios_1.default.post(this.baseUrl, {
48
- model: "claude-3-sonnet-20240229",
57
+ model: "claude-3-haiku-20240307",
49
58
  max_tokens: 2000,
50
59
  messages: [
51
60
  {
@@ -57,6 +66,7 @@ class ClaudeProvider extends provider_1.LLMProvider {
57
66
  headers: {
58
67
  "x-api-key": this.apiKey,
59
68
  "anthropic-version": "2023-06-01",
69
+ "anthropic-beta": "messages-2023-12-15",
60
70
  "Content-Type": "application/json",
61
71
  },
62
72
  timeout: 30000,
@@ -73,7 +83,10 @@ class ClaudeProvider extends provider_1.LLMProvider {
73
83
  };
74
84
  }
75
85
  catch (error) {
76
- throw new Error(`Failed to generate code with Claude: ${error instanceof Error ? error.message : String(error)}`);
86
+ const errorMessage = error.response
87
+ ? `HTTP ${error.response.status}: ${error.response.data?.error?.message || error.response.data}`
88
+ : error.message;
89
+ throw new Error(`Failed to generate code with Claude: ${errorMessage}`);
77
90
  }
78
91
  }
79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"version": "1.0.4",
3
+ "version": "1.0.7",
4
4
  "description": "Generate Playwright test cases from natural language using LLM",
5
5
  "main": "dist/index.js",
6
6
  "bin": {