From 023c04517bbc76d05c66688622a221c745f7bb37 Mon Sep 17 00:00:00 2001 From: CharlieHelps Date: Thu, 16 Oct 2025 23:30:52 +0000 Subject: [PATCH 1/6] test(jsx-email): snapshot for minimal nested in --- .../conditional-raw-minimal.test.tsx.snap | 3 ++ .../test/conditional-raw-minimal.test.tsx | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 packages/jsx-email/test/.snapshots/conditional-raw-minimal.test.tsx.snap create mode 100644 packages/jsx-email/test/conditional-raw-minimal.test.tsx diff --git a/packages/jsx-email/test/.snapshots/conditional-raw-minimal.test.tsx.snap b/packages/jsx-email/test/.snapshots/conditional-raw-minimal.test.tsx.snap new file mode 100644 index 00000000..bbb51985 --- /dev/null +++ b/packages/jsx-email/test/.snapshots/conditional-raw-minimal.test.tsx.snap @@ -0,0 +1,3 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`snapshot: minimal inside > renders a minimal MSO block with inlined Raw content 1`] = `""`; diff --git a/packages/jsx-email/test/conditional-raw-minimal.test.tsx b/packages/jsx-email/test/conditional-raw-minimal.test.tsx new file mode 100644 index 00000000..9488e326 --- /dev/null +++ b/packages/jsx-email/test/conditional-raw-minimal.test.tsx @@ -0,0 +1,31 @@ +// @ts-ignore +import React from 'react'; + +import { jsxToString } from '../src/renderer/jsx-to-string.js'; +import { Conditional } from '../src/components/conditional.js'; +import { Raw } from '../src/components/raw.js'; + +/** + * Minimal snapshot fixture for `` nested inside ``. + * + * This test intentionally asserts a snapshot of whatever the current + * render pipeline produces for this structure so we can iterate on it + * in follow‑ups. There are no behavioral assertions beyond the snapshot. + */ +describe('snapshot: minimal inside ', async () => { + beforeEach(() => { + vi.restoreAllMocks(); + vi.resetModules(); + }); + + it('renders a minimal MSO block with inlined Raw content', async () => { + const fragment = ( + + hello'} /> + + ); + + const html = await jsxToString(fragment); + expect(html).toMatchSnapshot(); + }); +}); From 4f1c709e8110a8015b79b3f23fbe1741259e0938 Mon Sep 17 00:00:00 2001 From: CharlieHelps Date: Thu, 16 Oct 2025 23:34:47 +0000 Subject: [PATCH 2/6] build(plugin-inline,plugin-minify): declare ESM by adding `"type": "module"` Add package.json with `"type": "module"` to both packages so Node treats their .js files as ESM. This aligns module semantics across the repo, prevents CJS fallback, and ensures correct import/export behavior, which helps with upcoming snapshot tests and minimal fixtures discussed in #316. --- packages/plugin-inline/src/package.json | 3 +++ packages/plugin-minify/src/package.json | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 packages/plugin-inline/src/package.json create mode 100644 packages/plugin-minify/src/package.json diff --git a/packages/plugin-inline/src/package.json b/packages/plugin-inline/src/package.json new file mode 100644 index 00000000..3dbc1ca5 --- /dev/null +++ b/packages/plugin-inline/src/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/plugin-minify/src/package.json b/packages/plugin-minify/src/package.json new file mode 100644 index 00000000..3dbc1ca5 --- /dev/null +++ b/packages/plugin-minify/src/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} From 588b96596f7a8242e8a249cbb637e5ad15e1c4dc Mon Sep 17 00:00:00 2001 From: CharlieHelps Date: Thu, 16 Oct 2025 23:46:31 +0000 Subject: [PATCH 3/6] revert(plugin-inline,plugin-minify): remove src/package.json "type": "module" per review --- packages/plugin-inline/src/package.json | 3 --- packages/plugin-minify/src/package.json | 3 --- 2 files changed, 6 deletions(-) delete mode 100644 packages/plugin-inline/src/package.json delete mode 100644 packages/plugin-minify/src/package.json diff --git a/packages/plugin-inline/src/package.json b/packages/plugin-inline/src/package.json deleted file mode 100644 index 3dbc1ca5..00000000 --- a/packages/plugin-inline/src/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "module" -} diff --git a/packages/plugin-minify/src/package.json b/packages/plugin-minify/src/package.json deleted file mode 100644 index 3dbc1ca5..00000000 --- a/packages/plugin-minify/src/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "module" -} From a9fc9986846c05cb8d2ba260af1af035b2c3de7d Mon Sep 17 00:00:00 2001 From: CharlieHelps Date: Fri, 17 Oct 2025 00:06:14 +0000 Subject: [PATCH 4/6] test(jsx-email): remove React import/TS-ignore and make describe synchronous\n\nPer review on PR #321: drop unused React default import guarded by ts-ignore, switch describe to sync, and remove unnecessary beforeEach/reset calls in minimal Conditional+Raw snapshot test. --- .../jsx-email/test/conditional-raw-minimal.test.tsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/jsx-email/test/conditional-raw-minimal.test.tsx b/packages/jsx-email/test/conditional-raw-minimal.test.tsx index 9488e326..468d74c5 100644 --- a/packages/jsx-email/test/conditional-raw-minimal.test.tsx +++ b/packages/jsx-email/test/conditional-raw-minimal.test.tsx @@ -1,6 +1,3 @@ -// @ts-ignore -import React from 'react'; - import { jsxToString } from '../src/renderer/jsx-to-string.js'; import { Conditional } from '../src/components/conditional.js'; import { Raw } from '../src/components/raw.js'; @@ -12,12 +9,7 @@ import { Raw } from '../src/components/raw.js'; * render pipeline produces for this structure so we can iterate on it * in follow‑ups. There are no behavioral assertions beyond the snapshot. */ -describe('snapshot: minimal inside ', async () => { - beforeEach(() => { - vi.restoreAllMocks(); - vi.resetModules(); - }); - +describe('snapshot: minimal inside ', () => { it('renders a minimal MSO block with inlined Raw content', async () => { const fragment = ( From 36de5c02c496ca4979ecbbcaaf91164c741c3234 Mon Sep 17 00:00:00 2001 From: CharlieHelps Date: Fri, 17 Oct 2025 00:13:48 +0000 Subject: [PATCH 5/6] test(jsx-email): also snapshot render() output for inside ; drop React import, make describe sync, and stub plugins for vitest collection --- .../conditional-raw-minimal.test.tsx.snap | 2 + .../test/conditional-raw-minimal.test.tsx | 38 +++++++++++++++---- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/packages/jsx-email/test/.snapshots/conditional-raw-minimal.test.tsx.snap b/packages/jsx-email/test/.snapshots/conditional-raw-minimal.test.tsx.snap index bbb51985..a5adc3d2 100644 --- a/packages/jsx-email/test/.snapshots/conditional-raw-minimal.test.tsx.snap +++ b/packages/jsx-email/test/.snapshots/conditional-raw-minimal.test.tsx.snap @@ -1,3 +1,5 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`snapshot: minimal inside > renders a minimal MSO block with inlined Raw content 1`] = `""`; + +exports[`snapshot: minimal inside > renders final HTML via the render pipeline 1`] = `""`; diff --git a/packages/jsx-email/test/conditional-raw-minimal.test.tsx b/packages/jsx-email/test/conditional-raw-minimal.test.tsx index 468d74c5..f671cc17 100644 --- a/packages/jsx-email/test/conditional-raw-minimal.test.tsx +++ b/packages/jsx-email/test/conditional-raw-minimal.test.tsx @@ -1,7 +1,32 @@ import { jsxToString } from '../src/renderer/jsx-to-string.js'; +import { render } from '../src/renderer/render.js'; import { Conditional } from '../src/components/conditional.js'; import { Raw } from '../src/components/raw.js'; +// We stub core plugins to keep the bundler from trying to resolve unpublished build outputs +// during test collection. These stubs are no-ops; we're not testing plugin behavior here. +vi.mock('@jsx-email/plugin-inline', () => { + return { + plugin: { name: '@jsx-email/plugin-inline', symbol: Symbol.for('jsx-email/plugin') } + }; +}); +vi.mock('@jsx-email/plugin-minify', () => { + return { + plugin: { name: '@jsx-email/plugin-minify', symbol: Symbol.for('jsx-email/plugin') } + }; +}); +vi.mock('@jsx-email/plugin-pretty', () => { + return { + plugin: { name: '@jsx-email/plugin-pretty', symbol: Symbol.for('jsx-email/plugin') } + }; +}); + +const minimalFragment = ( + + hello'} /> + +); + /** * Minimal snapshot fixture for `` nested inside ``. * @@ -10,14 +35,13 @@ import { Raw } from '../src/components/raw.js'; * in follow‑ups. There are no behavioral assertions beyond the snapshot. */ describe('snapshot: minimal inside ', () => { - it('renders a minimal MSO block with inlined Raw content', async () => { - const fragment = ( - - hello'} /> - - ); + it('renders a minimal MSO block with inlined Raw content (jsxToString)', async () => { + const html = await jsxToString(minimalFragment); + expect(html).toMatchSnapshot(); + }); - const html = await jsxToString(fragment); + it('renders final HTML via the render pipeline (with plugin stubs)', async () => { + const html = await render(minimalFragment); expect(html).toMatchSnapshot(); }); }); From be7246e80114948c516da83f8d292cab033a170b Mon Sep 17 00:00:00 2001 From: CharlieHelps Date: Fri, 17 Oct 2025 00:23:28 +0000 Subject: [PATCH 6/6] test(jsx-email): remove plugin stubs; build plugins via moon and update snapshot\n\nPer review on PR #321: drop vi.mock stubs for @jsx-email/plugin-* and rely on Moon builds for local runs. Updated the render() snapshot to reflect current output and removed an obsolete snapshot entry. --- .../conditional-raw-minimal.test.tsx.snap | 4 ++-- .../test/conditional-raw-minimal.test.tsx | 20 +------------------ 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/packages/jsx-email/test/.snapshots/conditional-raw-minimal.test.tsx.snap b/packages/jsx-email/test/.snapshots/conditional-raw-minimal.test.tsx.snap index a5adc3d2..33503461 100644 --- a/packages/jsx-email/test/.snapshots/conditional-raw-minimal.test.tsx.snap +++ b/packages/jsx-email/test/.snapshots/conditional-raw-minimal.test.tsx.snap @@ -1,5 +1,5 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`snapshot: minimal inside > renders a minimal MSO block with inlined Raw content 1`] = `""`; +exports[`snapshot: minimal inside > renders a minimal MSO block with inlined Raw content (jsxToString) 1`] = `""`; -exports[`snapshot: minimal inside > renders final HTML via the render pipeline 1`] = `""`; +exports[`snapshot: minimal inside > renders final HTML via the render pipeline 1`] = `""`; diff --git a/packages/jsx-email/test/conditional-raw-minimal.test.tsx b/packages/jsx-email/test/conditional-raw-minimal.test.tsx index f671cc17..7ce5e5cf 100644 --- a/packages/jsx-email/test/conditional-raw-minimal.test.tsx +++ b/packages/jsx-email/test/conditional-raw-minimal.test.tsx @@ -3,24 +3,6 @@ import { render } from '../src/renderer/render.js'; import { Conditional } from '../src/components/conditional.js'; import { Raw } from '../src/components/raw.js'; -// We stub core plugins to keep the bundler from trying to resolve unpublished build outputs -// during test collection. These stubs are no-ops; we're not testing plugin behavior here. -vi.mock('@jsx-email/plugin-inline', () => { - return { - plugin: { name: '@jsx-email/plugin-inline', symbol: Symbol.for('jsx-email/plugin') } - }; -}); -vi.mock('@jsx-email/plugin-minify', () => { - return { - plugin: { name: '@jsx-email/plugin-minify', symbol: Symbol.for('jsx-email/plugin') } - }; -}); -vi.mock('@jsx-email/plugin-pretty', () => { - return { - plugin: { name: '@jsx-email/plugin-pretty', symbol: Symbol.for('jsx-email/plugin') } - }; -}); - const minimalFragment = ( hello'} /> @@ -40,7 +22,7 @@ describe('snapshot: minimal inside ', () => { expect(html).toMatchSnapshot(); }); - it('renders final HTML via the render pipeline (with plugin stubs)', async () => { + it('renders final HTML via the render pipeline', async () => { const html = await render(minimalFragment); expect(html).toMatchSnapshot(); });