@specwright/plugin 0.1.3 → 0.1.4

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.
@@ -11,9 +11,12 @@
11
11
  */
12
12
 
13
13
  import { expect } from '@playwright/test';
14
- import _ from 'lodash';
15
14
  import { generateValueForField } from './testDataGenerator.js';
16
15
 
16
+ // Simple replacements for lodash — avoids a dependency for 2 functions
17
+ const snakeCase = (str) => str.replace(/([a-z])([A-Z])/g, '$1_$2').replace(/[\s\-]+/g, '_').toLowerCase();
18
+ const kebabCase = (str) => str.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/[\s_]+/g, '-').toLowerCase();
19
+
17
20
  // ─────────────────────────────────────────────────────────────
18
21
  // FIELD_TYPES — declarative type constants
19
22
  // ─────────────────────────────────────────────────────────────
@@ -76,7 +79,7 @@ export async function processDataTable(page, dataTable, config = {}) {
76
79
  }
77
80
  // Cache SharedGenerated values for later <from_test_data> reads
78
81
  if (valueType === 'sharedgenerated') {
79
- const cacheKey = mapping[fieldName] || _.snakeCase(fieldName);
82
+ const cacheKey = mapping[fieldName] || snakeCase(fieldName);
80
83
  if (!page.testData) page.testData = {};
81
84
  page.testData[cacheKey] = value;
82
85
  // Also write to featureDataCache for cross-scenario persistence
@@ -90,7 +93,7 @@ export async function processDataTable(page, dataTable, config = {}) {
90
93
  }
91
94
  } else if (value === '<from_test_data>') {
92
95
  // Read: look up from page.testData or featureDataCache
93
- const cacheKey = mapping[fieldName] || _.snakeCase(fieldName);
96
+ const cacheKey = mapping[fieldName] || snakeCase(fieldName);
94
97
  if (page.testData?.[cacheKey] !== undefined) {
95
98
  value = page.testData[cacheKey];
96
99
  console.log(`📖 Read "${fieldName}" → ${cacheKey}: ${value}`);
@@ -146,7 +149,7 @@ export async function validateExpectations(page, dataTable, config = {}) {
146
149
 
147
150
  // ── Resolve <from_test_data> placeholder ──
148
151
  if (expectedValue === '<from_test_data>') {
149
- const cacheKey = mapping[fieldName] || _.snakeCase(fieldName);
152
+ const cacheKey = mapping[fieldName] || snakeCase(fieldName);
150
153
  if (page.testData?.[cacheKey] !== undefined) {
151
154
  expectedValue = page.testData[cacheKey];
152
155
  console.log(`✅ Validate "${fieldName}" → ${cacheKey}: ${expectedValue}`);
@@ -184,7 +187,7 @@ export async function validateExpectations(page, dataTable, config = {}) {
184
187
  * Tries: testID → name → placeholder → label → CSS fallback
185
188
  */
186
189
  export async function fillFieldByName(container, fieldName, value) {
187
- const fieldKebab = _.kebabCase(fieldName);
190
+ const fieldKebab = kebabCase(fieldName);
188
191
 
189
192
  const strategies = [
190
193
  () => container.getByTestId(fieldKebab),
@@ -221,7 +224,7 @@ export async function fillFieldByName(container, fieldName, value) {
221
224
  * Opens the dropdown, finds the option by text, clicks it.
222
225
  */
223
226
  export async function selectDropDownByTestId(page, fieldName, value, autoKebab = true) {
224
- const testId = autoKebab ? _.kebabCase(fieldName) : fieldName;
227
+ const testId = autoKebab ? kebabCase(fieldName) : fieldName;
225
228
 
226
229
  const dropdownContainer = page.getByTestId(testId);
227
230
  await dropdownContainer.waitFor({ state: 'visible', timeout: 5000 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@specwright/plugin",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Drop-in E2E test automation framework plugin — Playwright BDD + Claude Code agents",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -21,7 +21,6 @@
21
21
  "@faker-js/faker": "^10.3.0",
22
22
  "@playwright/test": "^1.54.1",
23
23
  "dotenv": "^17.2.0",
24
- "lodash": "^4.17.23",
25
24
  "playwright-bdd": "^8.5.0"
26
25
  }
27
26
  }