Skip to content

Commit 62d4051

Browse files
committed
test: Rollup - add config tests
1 parent ce3836b commit 62d4051

File tree

6 files changed

+60
-735
lines changed

6 files changed

+60
-735
lines changed

test/package/rollup/case-config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* eslint-disable @typescript-eslint/no-require-imports */
2+
const { defineConfig } = require('rollup');
3+
const webpackStatsPlugin = require('rollup-plugin-webpack-stats');
4+
5+
module.exports = defineConfig({
6+
input: 'src/index.js',
7+
output: {
8+
dir: 'dist',
9+
},
10+
plugins: [webpackStatsPlugin()],
11+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from 'rollup';
2+
import webpackStatsPlugin from 'rollup-plugin-webpack-stats';
3+
4+
export default defineConfig({
5+
input: 'src/index.js',
6+
output: {
7+
dir: 'dist',
8+
},
9+
plugins: [webpackStatsPlugin()],
10+
});

test/package/rollup/case-config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from 'rollup';
2+
import webpackStatsPlugin from 'rollup-plugin-webpack-stats';
3+
4+
export default defineConfig({
5+
input: 'src/index.js',
6+
output: {
7+
dir: 'dist',
8+
},
9+
plugins: [webpackStatsPlugin({})],
10+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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('package - rollup configs', () => {
14+
testCases.forEach((testCase) => {
15+
test(`should build successfully with rollup ${testCase.type} config`, async () => {
16+
const { stderr } = await exec(`cross-env NO_COLOR=true ${testCase.run}`);
17+
18+
expect(stderr).toMatch('Stats saved to dist');
19+
expect(stderr).toMatch('created dist in');
20+
});
21+
});
22+
});

0 commit comments

Comments
 (0)