diff --git a/.changeset/config.json b/.changeset/config.json index 013fcc2b..360bebc4 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -1,7 +1,7 @@ { "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json", "changelog": "@changesets/cli/changelog", - "commit": false, + "commit": ["@changesets/cli/commit", { "skipCI": false }], "fixed": [], "linked": [], "access": "restricted", diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index bdd84843..6fa0e96c 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -1,5 +1,11 @@ # esbuild-plugin-react18 +## 0.2.5 + +### Patch Changes + +- Do not build snap files. + ## 0.2.4 ### Patch Changes diff --git a/lib/__tests__/dist.test.ts b/lib/__tests__/dist.test.ts index 0c8e4a3b..7d50edac 100644 --- a/lib/__tests__/dist.test.ts +++ b/lib/__tests__/dist.test.ts @@ -23,4 +23,10 @@ describe.concurrent("Test plugin with default options in example build with tsup const text = fs.readFileSync(path.resolve(exampleBuildDir, "client", "index.js"), "utf-8"); expect(/data-testid/.test(text)).toBe(false); }); + + test("should not contain .snap files", ({ expect }) => { + expect(fs.existsSync(path.resolve(exampleBuildDir, "client", "header", "__snapshots__"))).toBe( + false, + ); + }); }); diff --git a/lib/package.json b/lib/package.json index c3e67b25..7058e008 100644 --- a/lib/package.json +++ b/lib/package.json @@ -2,7 +2,7 @@ "name": "esbuild-plugin-react18", "author": "Mayank Kumar Chaudhari ", "private": false, - "version": "0.2.4", + "version": "0.2.5", "description": "Unlock the Potential of React Server Components! Harness the power of an ESBuild plugin designed for crafting libraries compatible with RSC (React18 Server Components).", "license": "MPL-2.0", "main": "./dist/index.js", diff --git a/lib/src/index.ts b/lib/src/index.ts index a84cd1fa..2f745e7e 100644 --- a/lib/src/index.ts +++ b/lib/src/index.ts @@ -5,7 +5,7 @@ import path from "node:path"; const uuid = () => (Date.now() * Math.random()).toString(36).slice(0, 8); /** regExp */ -const testPathRegExp = /.*\.(test|spec|check)\.(j|t)s(x)?$/i; +const testPathRegExp = /.*\.(test|spec|check)\.[jt]sx?|spec$/i; const name = "esbuild-plugin-react18-" + uuid(); const ignoreNamespace = "mayank1513-ignore-" + uuid(); @@ -46,7 +46,7 @@ export interface React18PluginOptions { * to avoid any unexpected results. * * Caution! - if you have not enabled `keepTests`, we are already using - * `/.*\.(j|t)s(x)?$/` pattern to remove ` + * `/.*\.[jt]sx?$/` pattern to remove ` data-testid` attributes. If your * `sourceReplacePatterns` collide with these files, please set `keepTestIds` @@ -76,7 +76,7 @@ function removeTests(build: PluginBuild, options: React18PluginOptions) { /** remove data-testid */ if (!options.sourceReplacePatterns) options.sourceReplacePatterns = []; options.sourceReplacePatterns.push({ - pathPattern: /.*\.(j|t)s(x)?$/, + pathPattern: /.*\.[jt]sx?$/, replaceParams: [{ pattern: /\s*data-testid="[^"]*"/gm, substitute: " " }], }); } diff --git a/packages/shared/src/client/header/__snapshots__/header.test.tsx.snap b/packages/shared/src/client/header/__snapshots__/header.test.tsx.snap new file mode 100644 index 00000000..9122e16f --- /dev/null +++ b/packages/shared/src/client/header/__snapshots__/header.test.tsx.snap @@ -0,0 +1,54 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`header > snapshot 1`] = ` +
+
+
+ + + + esbuild-plugin-react18 + + + +
+
+
+`; diff --git a/packages/shared/src/client/header/header.test.tsx b/packages/shared/src/client/header/header.test.tsx index 06f305fe..6126df93 100644 --- a/packages/shared/src/client/header/header.test.tsx +++ b/packages/shared/src/client/header/header.test.tsx @@ -8,4 +8,8 @@ describe.concurrent("header", () => { test("check if h1 heading exists", () => { render(
); }); + test("snapshot", ({ expect }) => { + const { container } = render(
); + expect(container).toMatchSnapshot(); + }); });