Skip to content

Commit 9706fb1

Browse files
authored
Merge de43f5f into d5ca550
2 parents d5ca550 + de43f5f commit 9706fb1

File tree

3 files changed

+40
-27
lines changed

3 files changed

+40
-27
lines changed

examples/plugins/src/file-size/src/file-size.plugin.int.test.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { vol } from 'memfs';
2-
import { beforeEach, describe, expect, it } from 'vitest';
1+
import { mkdir, rm, writeFile } from 'node:fs/promises';
2+
import path from 'node:path';
3+
import { describe, expect, it } from 'vitest';
34
import { executePlugin } from '@code-pushup/core';
45
import {
56
auditSchema,
67
categoryRefSchema,
78
pluginConfigSchema,
89
} from '@code-pushup/models';
9-
import { MEMFS_VOLUME } from '@code-pushup/test-utils';
1010
import {
1111
type PluginOptions,
1212
audits,
@@ -27,24 +27,31 @@ const projectJson = JSON.stringify(
2727
2,
2828
);
2929
const testJs = `
30-
const str = 'Hello World'
31-
const num = 42;
32-
const obj = ${projectJson};
33-
`;
30+
const str = 'Hello World';
31+
const num = 42;
32+
const obj = ${projectJson};
33+
`;
3434

3535
describe('create', () => {
36+
const workDir = path.join(
37+
'tmp',
38+
'int-tests',
39+
'examples-plugins',
40+
'package-json',
41+
);
42+
3643
const baseOptions: PluginOptions = {
37-
directory: '/',
44+
directory: workDir,
3845
};
3946

40-
beforeEach(() => {
41-
vol.fromJSON(
42-
{
43-
'project.json': projectJson,
44-
'src/test.js': testJs,
45-
},
46-
MEMFS_VOLUME,
47-
);
47+
beforeAll(async () => {
48+
await mkdir(workDir, { recursive: true });
49+
await writeFile(path.join(workDir, 'project.json'), projectJson);
50+
await writeFile(path.join(workDir, 'test.js'), testJs);
51+
});
52+
53+
afterAll(async () => {
54+
await rm(workDir, { recursive: true, force: true });
4855
});
4956

5057
it('should return valid PluginConfig', () => {

examples/plugins/src/package-json/src/package-json.plugin.int.test.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { vol } from 'memfs';
1+
import { mkdir, rm, writeFile } from 'node:fs/promises';
2+
import path from 'node:path';
23
import { describe, expect, it } from 'vitest';
34
import { executePlugin } from '@code-pushup/core';
45
import {
@@ -7,7 +8,6 @@ import {
78
pluginConfigSchema,
89
pluginReportSchema,
910
} from '@code-pushup/models';
10-
import { MEMFS_VOLUME } from '@code-pushup/test-utils';
1111
import { audits, pluginSlug as slug } from './constants.js';
1212
import { type PluginOptions, create } from './package-json.plugin.js';
1313
import {
@@ -18,17 +18,24 @@ import {
1818
} from './scoring.js';
1919

2020
describe('create-package-json', () => {
21+
const workDir = path.join(
22+
'tmp',
23+
'int-tests',
24+
'examples-plugins',
25+
'package-json',
26+
);
27+
2128
const baseOptions: PluginOptions = {
22-
directory: '/',
29+
directory: workDir,
2330
};
2431

25-
beforeEach(() => {
26-
vol.fromJSON(
27-
{
28-
'package.json': '{}',
29-
},
30-
MEMFS_VOLUME,
31-
);
32+
beforeAll(async () => {
33+
await mkdir(workDir, { recursive: true });
34+
await writeFile(path.join(workDir, 'package.json'), '{}');
35+
});
36+
37+
afterAll(async () => {
38+
await rm(workDir, { recursive: true, force: true });
3239
});
3340

3441
it('should return valid PluginConfig', () => {

examples/plugins/vitest.int.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export default defineConfig({
2222
include: ['src/**/*.int.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
2323
globalSetup: ['../../global-setup.ts'],
2424
setupFiles: [
25-
'../../testing/test-setup/src/lib/fs.mock.ts',
2625
'../../testing/test-setup/src/lib/git.mock.ts',
2726
'../../testing/test-setup/src/lib/console.mock.ts',
2827
'../../testing/test-setup/src/lib/reset.mocks.ts',

0 commit comments

Comments
 (0)