Skip to content

Commit 4cc830d

Browse files
authored
Merge pull request #29 from react18-tools/fix/28-snapshot
Fix/28 snapshot
2 parents 20db2b8 + f815224 commit 4cc830d

File tree

7 files changed

+75
-5
lines changed

7 files changed

+75
-5
lines changed

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
33
"changelog": "@changesets/cli/changelog",
4-
"commit": false,
4+
"commit": ["@changesets/cli/commit", { "skipCI": false }],
55
"fixed": [],
66
"linked": [],
77
"access": "restricted",

lib/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# esbuild-plugin-react18
22

3+
## 0.2.5
4+
5+
### Patch Changes
6+
7+
- Do not build snap files.
8+
39
## 0.2.4
410

511
### Patch Changes

lib/__tests__/dist.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,10 @@ describe.concurrent("Test plugin with default options in example build with tsup
2323
const text = fs.readFileSync(path.resolve(exampleBuildDir, "client", "index.js"), "utf-8");
2424
expect(/data-testid/.test(text)).toBe(false);
2525
});
26+
27+
test("should not contain .snap files", ({ expect }) => {
28+
expect(fs.existsSync(path.resolve(exampleBuildDir, "client", "header", "__snapshots__"))).toBe(
29+
false,
30+
);
31+
});
2632
});

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "esbuild-plugin-react18",
33
"author": "Mayank Kumar Chaudhari <https://mayank-chaudhari.vercel.app>",
44
"private": false,
5-
"version": "0.2.4",
5+
"version": "0.2.5",
66
"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).",
77
"license": "MPL-2.0",
88
"main": "./dist/index.js",

lib/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from "node:path";
55
const uuid = () => (Date.now() * Math.random()).toString(36).slice(0, 8);
66

77
/** regExp */
8-
const testPathRegExp = /.*\.(test|spec|check)\.(j|t)s(x)?$/i;
8+
const testPathRegExp = /.*\.(test|spec|check)\.[jt]sx?|spec$/i;
99

1010
const name = "esbuild-plugin-react18-" + uuid();
1111
const ignoreNamespace = "mayank1513-ignore-" + uuid();
@@ -46,7 +46,7 @@ export interface React18PluginOptions {
4646
* to avoid any unexpected results.
4747
*
4848
* Caution! - if you have not enabled `keepTests`, we are already using
49-
* `/.*\.(j|t)s(x)?$/` pattern to remove `
49+
* `/.*\.[jt]sx?$/` pattern to remove `
5050
5151
data-testid` attributes. If your
5252
* `sourceReplacePatterns` collide with these files, please set `keepTestIds`
@@ -76,7 +76,7 @@ function removeTests(build: PluginBuild, options: React18PluginOptions) {
7676
/** remove data-testid */
7777
if (!options.sourceReplacePatterns) options.sourceReplacePatterns = [];
7878
options.sourceReplacePatterns.push({
79-
pathPattern: /.*\.(j|t)s(x)?$/,
79+
pathPattern: /.*\.[jt]sx?$/,
8080
replaceParams: [{ pattern: /\s*data-testid="[^"]*"/gm, substitute: " " }],
8181
});
8282
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`header > snapshot 1`] = `
4+
<div>
5+
<header
6+
class="_header_66b73e"
7+
>
8+
<div>
9+
<button
10+
class="_drawerBtn_457bb3 mb "
11+
>
12+
<div />
13+
<div />
14+
<div />
15+
</button>
16+
<a
17+
class="_logo_f9173e"
18+
href="/"
19+
rel="noopener noreferrer"
20+
target="_blank"
21+
>
22+
<span>
23+
esbuild-plugin-react18
24+
</span>
25+
</a>
26+
<nav
27+
class=""
28+
>
29+
<a
30+
class="_author_66b73e"
31+
href="https://mayank-chaudhari.vercel.app/"
32+
rel="noopener noreferrer"
33+
target="_blank"
34+
>
35+
By Mayank Chaudhari
36+
</a>
37+
<button
38+
class="_themeswitch_66b73e"
39+
>
40+
<button
41+
class="nth-s nth-system "
42+
style="--s: 25px;"
43+
/>
44+
<span
45+
class="mb"
46+
>
47+
system
48+
</span>
49+
</button>
50+
</nav>
51+
</div>
52+
</header>
53+
</div>
54+
`;

packages/shared/src/client/header/header.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ describe.concurrent("header", () => {
88
test("check if h1 heading exists", () => {
99
render(<Header />);
1010
});
11+
test("snapshot", ({ expect }) => {
12+
const { container } = render(<Header />);
13+
expect(container).toMatchSnapshot();
14+
});
1115
});

0 commit comments

Comments
 (0)