|
| 1 | +import { test } from 'uvu'; |
| 2 | +import * as assert from 'uvu/assert'; |
| 3 | + |
| 4 | +import { setupTest, teardownTest, loadFixture, viteBuild, viteBuildCli } from './lib/lifecycle.js'; |
| 5 | + |
| 6 | +let env; |
| 7 | +test.before.each(async () => { |
| 8 | + env = await setupTest(); |
| 9 | +}); |
| 10 | + |
| 11 | +test.after.each(async () => { |
| 12 | + await teardownTest(env); |
| 13 | +}); |
| 14 | + |
| 15 | +test('Should skip plugin during SSR build', async () => { |
| 16 | + await loadFixture('environments/ssr', env); |
| 17 | + |
| 18 | + let message = ''; |
| 19 | + try { |
| 20 | + await viteBuild(env.tmp.path); |
| 21 | + } catch (error) { |
| 22 | + message = error.message; |
| 23 | + } |
| 24 | + |
| 25 | + assert.match(message, ''); |
| 26 | +}); |
| 27 | + |
| 28 | +test('Should skip plugin during SSR build (CLI)', async () => { |
| 29 | + await loadFixture('simple', env); |
| 30 | + const output = await viteBuildCli(env.tmp.path, ['--ssr', 'src/index.js']); |
| 31 | + await output.done; |
| 32 | + |
| 33 | + assert.equal(output.stderr, []); |
| 34 | +}); |
| 35 | + |
| 36 | +test('Should skip plugin during non-client environment build (Cloudflare plugin)', async () => { |
| 37 | + await loadFixture('environments/cloudflare', env); |
| 38 | + const output = await viteBuildCli(env.tmp.path); |
| 39 | + await output.done; |
| 40 | + |
| 41 | + assert.equal(output.stderr, []); |
| 42 | +}); |
| 43 | + |
| 44 | +test.run(); |
0 commit comments