From df7f75341b56670e1270771d8a8dcb16d44abf54 Mon Sep 17 00:00:00 2001 From: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com> Date: Thu, 4 Jan 2024 11:28:55 +1100 Subject: [PATCH] test: Ensure all dist and snap files match --- integrations/react/tests/build.test.ts | 9 ++++++++- integrations/vue/tests/build.test.ts | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/integrations/react/tests/build.test.ts b/integrations/react/tests/build.test.ts index e30aba5..1ce5288 100644 --- a/integrations/react/tests/build.test.ts +++ b/integrations/react/tests/build.test.ts @@ -1,4 +1,4 @@ -import { readFileSync } from 'node:fs' +import { readFileSync, readdirSync } from 'node:fs' import { fileURLToPath } from 'node:url' import { dirname, resolve } from 'node:path' import { describe, expect, it } from 'vitest' @@ -12,6 +12,13 @@ const cjsExtensions = ['.cjs', '.cjs.map', '.d.cts'] const files = ['index', 'use-client', 'nested/nested'] describe('Check React build output', () => { + it('should output the same file structure', () => { + const distFiles = readdirSync(`${rootDir}/dist`, { recursive: true }) + const snapFiles = readdirSync(`${rootDir}/snap`, { recursive: true }) + + expect(distFiles).toEqual(snapFiles) + }) + it('should build the same ESM output', () => { files.forEach((file) => { esmExtensions.forEach((ext) => { diff --git a/integrations/vue/tests/build.test.ts b/integrations/vue/tests/build.test.ts index 4849589..923a883 100644 --- a/integrations/vue/tests/build.test.ts +++ b/integrations/vue/tests/build.test.ts @@ -1,4 +1,4 @@ -import { readFileSync } from 'node:fs' +import { readFileSync, readdirSync } from 'node:fs' import { fileURLToPath } from 'node:url' import { dirname, resolve } from 'node:path' import { describe, expect, it } from 'vitest' @@ -9,9 +9,16 @@ const rootDir = resolve(__dirname, '..') const esmExtensions = ['.js', '.js.map', '.d.ts'] const cjsExtensions = ['.cjs', '.cjs.map', '.d.cts'] -const files = ['index'] +const files = ['index', 'App.vue', 'components/HelloWorld.vue'] describe('Check Vite build output', () => { + it('should output the same file structure', () => { + const distFiles = readdirSync(`${rootDir}/dist`, { recursive: true }) + const snapFiles = readdirSync(`${rootDir}/snap`, { recursive: true }) + + expect(distFiles).toEqual(snapFiles) + }) + it('should build the same ESM output', () => { files.forEach((file) => { esmExtensions.forEach((ext) => {