Skip to content

Commit 901e07b

Browse files
committed
test: Vite - add cases for commonjs,mjs,ts configs
1 parent f88f54d commit 901e07b

File tree

8 files changed

+1283
-29
lines changed

8 files changed

+1283
-29
lines changed

test/package/vite/configs.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { promisify } from 'node:util';
2+
import { exec as execCallback} from 'node:child_process';
3+
import { describe, expect, test } from 'vitest';
4+
5+
const exec = promisify(execCallback);
6+
7+
const testCases = [
8+
{ type: 'commonjs', run: 'npm run build-commonjs' },
9+
{ type: 'esm', run: 'npm run build-esm' },
10+
{ type: 'ts', run: 'npm run build-ts' },
11+
];
12+
13+
describe('rollup package - configs', () => {
14+
testCases.forEach((testCase) => {
15+
test(`should build successfully with rollup ${testCase.type} config`, async () => {
16+
const { stdout, stderr } = await exec(`cross-env NO_COLOR=true ${testCase.run}`);
17+
18+
console.log(stdout);
19+
20+
expect(stderr).toMatch('Stats saved to');
21+
expect(stderr).toMatch('built in');
22+
});
23+
});
24+
});

test/package/vite/vite-package.test.js renamed to test/package/vite/options.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { describe, test, expect, beforeEach } from 'vitest';
44
import { build as vite } from 'vite';
55
import { vol } from 'memfs';
66

7-
import config, { relativeFileNameConfig, absoluteFileNameConfig } from './vite.config';
7+
import config, { relativeFileNameConfig, absoluteFileNameConfig } from './vite-options.config';
88

99
describe('vite package test', () => {
1010
beforeEach(() => {

0 commit comments

Comments
 (0)