Skip to content

Commit 76e4125

Browse files
committed
update tests to vitest
1 parent 9a92f61 commit 76e4125

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

packages/babel/test/as-input-plugin.mjs

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -595,42 +595,39 @@ test('works as a CJS plugin', async () => {
595595
expect(code.includes('const')).toBe(false);
596596
});
597597

598-
test('works in parallel', async (t) => {
598+
test('works in parallel', async () => {
599599
const bundle = await rollup({
600600
input: `${FIXTURES}proposal-decorators/main.js`,
601601
plugins: [babelPlugin({ parallel: true })]
602602
});
603603
const code = await getCode(bundle);
604604

605-
t.true(code.includes('_createClass'), 'decorator was applied');
605+
expect(code.includes('_createClass')).toBe(true);
606606
});
607607

608-
test('works in parallel with specified worker count', async (t) => {
608+
test('works in parallel with specified worker count', async () => {
609609
const code = await generate('basic/main.js', { parallel: 2 });
610-
t.false(code.includes('const'));
611-
t.true(code.includes('var answer = 42'));
612-
});
613-
614-
test('throws when using parallel with non-serializable babel options', async (t) => {
615-
await t.throwsAsync(
616-
() =>
617-
generate('basic/main.js', {
618-
parallel: true,
619-
plugins: [
620-
// Functions are not serializable
621-
function customPlugin() {
622-
return { visitor: {} };
623-
}
624-
]
625-
}),
626-
{
627-
message:
628-
/Cannot use "parallel" mode alongside custom overrides or non-serializable Babel options/
629-
}
610+
expect(code.includes('const')).toBe(false);
611+
expect(code.includes('var answer = 42')).toBe(true);
612+
});
613+
614+
test('throws when using parallel with non-serializable babel options', async () => {
615+
await expect(() =>
616+
generate('basic/main.js', {
617+
parallel: true,
618+
plugins: [
619+
// Functions are not serializable
620+
function customPlugin() {
621+
return { visitor: {} };
622+
}
623+
]
624+
})
625+
).rejects.toThrow(
626+
/Cannot use "parallel" mode alongside custom overrides or non-serializable Babel options/
630627
);
631628
});
632629

633-
test('throws when using parallel with config override', (t) => {
630+
test('throws when using parallel with config override', () => {
634631
const customBabelPlugin = createBabelInputPluginFactory(() => {
635632
return {
636633
config(cfg) {
@@ -639,13 +636,12 @@ test('throws when using parallel with config override', (t) => {
639636
};
640637
});
641638

642-
t.throws(() => customBabelPlugin({ babelHelpers: 'bundled', parallel: true }), {
643-
message:
644-
/Cannot use "parallel" mode alongside custom overrides or non-serializable Babel options/
645-
});
639+
expect(() => customBabelPlugin({ babelHelpers: 'bundled', parallel: true })).toThrow(
640+
/Cannot use "parallel" mode alongside custom overrides or non-serializable Babel options/
641+
);
646642
});
647643

648-
test('throws when using parallel with result override', (t) => {
644+
test('throws when using parallel with result override', () => {
649645
const customBabelPlugin = createBabelInputPluginFactory(() => {
650646
return {
651647
result(result) {
@@ -654,8 +650,7 @@ test('throws when using parallel with result override', (t) => {
654650
};
655651
});
656652

657-
t.throws(() => customBabelPlugin({ babelHelpers: 'bundled', parallel: true }), {
658-
message:
659-
/Cannot use "parallel" mode alongside custom overrides or non-serializable Babel options/
660-
});
653+
expect(() => customBabelPlugin({ babelHelpers: 'bundled', parallel: true })).toThrow(
654+
/Cannot use "parallel" mode alongside custom overrides or non-serializable Babel options/
655+
);
661656
});

0 commit comments

Comments
 (0)