Skip to content

Commit 4f0cf8a

Browse files
committed
test: use configureVitest hook in async plugin factory snap test
1 parent 05dbe79 commit 4f0cf8a

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
14
export default function myVitestPlugin() {
25
return {
36
name: 'my-vitest-plugin',
4-
config() {
5-
return {
6-
test: {
7-
env: {
8-
MY_VITEST_PLUGIN_LOADED: '1',
9-
},
10-
},
11-
};
7+
configureVitest() {
8+
fs.writeFileSync(
9+
path.join(import.meta.dirname, '.vitest-plugin-loaded'),
10+
'configureVitest hook executed',
11+
);
1212
},
1313
};
1414
}
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
14
import { expect, test } from '@voidzero-dev/vite-plus-test';
25

3-
test('async plugin factory should load vitest plugin', () => {
4-
expect(process.env.MY_VITEST_PLUGIN_LOADED).toBe('1');
6+
test('async plugin factory should load vitest plugin with configureVitest hook', () => {
7+
const markerPath = path.join(import.meta.dirname, '..', '.vitest-plugin-loaded');
8+
expect(fs.existsSync(markerPath)).toBe(true);
9+
expect(fs.readFileSync(markerPath, 'utf-8')).toBe('configureVitest hook executed');
10+
fs.unlinkSync(markerPath);
511
});

0 commit comments

Comments
 (0)