@testspectra/react 1.2.5 → 1.2.6
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 +47 -27
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1249,34 +1249,53 @@ import * as esbuild from "esbuild";
|
|
|
1249
1249
|
import { createRequire as createRequire2 } from "node:module";
|
|
1250
1250
|
var bundleCache = /* @__PURE__ */ new Map();
|
|
1251
1251
|
var inFlightBuilds = /* @__PURE__ */ new Map();
|
|
1252
|
-
var
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
style.textContent = ${escaped};
|
|
1266
|
-
document.head.appendChild(style);
|
|
1267
|
-
}
|
|
1268
|
-
`,
|
|
1269
|
-
loader: "js"
|
|
1270
|
-
};
|
|
1271
|
-
} catch (e) {
|
|
1272
|
-
return {
|
|
1273
|
-
contents: `/* failed to load css: ${String(e)} */`,
|
|
1274
|
-
loader: "js"
|
|
1275
|
-
};
|
|
1276
|
-
}
|
|
1277
|
-
});
|
|
1252
|
+
var consumerRootForCss;
|
|
1253
|
+
var TAILWIND_CSS_HINT = /@import\s+['"]tailwindcss['"]|@tailwind\b|@source\b|@theme\b/;
|
|
1254
|
+
async function compileCss(raw, filePath) {
|
|
1255
|
+
const consumerRoot = consumerRootForCss;
|
|
1256
|
+
if (!consumerRoot || !TAILWIND_CSS_HINT.test(raw)) return raw;
|
|
1257
|
+
try {
|
|
1258
|
+
const req = createRequire2(path3.join(consumerRoot, "package.json"));
|
|
1259
|
+
const postcss = req("postcss");
|
|
1260
|
+
const tailwind = req("@tailwindcss/postcss");
|
|
1261
|
+
const result = await postcss([tailwind()]).process(raw, { from: filePath });
|
|
1262
|
+
return result.css;
|
|
1263
|
+
} catch {
|
|
1264
|
+
return raw;
|
|
1278
1265
|
}
|
|
1279
|
-
}
|
|
1266
|
+
}
|
|
1267
|
+
function createCssInjectorPlugin() {
|
|
1268
|
+
return {
|
|
1269
|
+
name: "spectra-css-injector",
|
|
1270
|
+
setup(build2) {
|
|
1271
|
+
build2.onLoad({ filter: /\.(css|scss|sass|less)$/ }, async (args) => {
|
|
1272
|
+
try {
|
|
1273
|
+
const raw = await fs.promises.readFile(args.path, "utf8");
|
|
1274
|
+
const css = await compileCss(raw, args.path);
|
|
1275
|
+
const escaped = JSON.stringify(css);
|
|
1276
|
+
const sourcePath = JSON.stringify(args.path);
|
|
1277
|
+
return {
|
|
1278
|
+
contents: `
|
|
1279
|
+
if (typeof document !== 'undefined') {
|
|
1280
|
+
const style = document.createElement('style');
|
|
1281
|
+
style.setAttribute('data-spectra-css', ${sourcePath});
|
|
1282
|
+
style.textContent = ${escaped};
|
|
1283
|
+
document.head.appendChild(style);
|
|
1284
|
+
}
|
|
1285
|
+
`,
|
|
1286
|
+
loader: "js"
|
|
1287
|
+
};
|
|
1288
|
+
} catch (e) {
|
|
1289
|
+
return {
|
|
1290
|
+
contents: `/* failed to load css: ${String(e)} */`,
|
|
1291
|
+
loader: "js"
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
}
|
|
1298
|
+
var cssInjectorPlugin = createCssInjectorPlugin();
|
|
1280
1299
|
var SHARED_REACT_EXTERNALS = [
|
|
1281
1300
|
"react",
|
|
1282
1301
|
"react/jsx-runtime",
|
|
@@ -1618,6 +1637,7 @@ function makeHandler(testRoot, packageDir, harnessHtml, setupEntrypoint, runnerE
|
|
|
1618
1637
|
}
|
|
1619
1638
|
async function startBundleServer(opts = {}) {
|
|
1620
1639
|
const testRoot = path3.resolve(opts.testRoot ?? process.cwd());
|
|
1640
|
+
consumerRootForCss = testRoot;
|
|
1621
1641
|
const packageDir = opts.packageDir ?? resolveReactPackageDir();
|
|
1622
1642
|
const manifest = opts.manifest ?? { pageObjects: [], steps: [], fixtures: [] };
|
|
1623
1643
|
const stepDelayMs = opts.stepDelayMs ?? 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testspectra/react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Bundled Vitest browser-mode runner for React component testing with the TestSpectra Spectra.* DSL",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"testspectra",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"esbuild": "^0.28.2",
|
|
43
43
|
"playwright": "^1.48.0",
|
|
44
44
|
"vitest": "^2.1.8",
|
|
45
|
-
"@testspectra/matchers": "1.2.
|
|
45
|
+
"@testspectra/matchers": "1.2.6"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": ">=18.0.0",
|