Skip to content

Commit e499cd3

Browse files
authored
Merge branch 'main' into renovate/chai-6.x
2 parents a1ff97a + 0005e5a commit e499cd3

File tree

98 files changed

+3279
-454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+3279
-454
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ test-results/
3434
fixtures-test/
3535
fixtures-test-*/
3636
.rslib/
37+
38+
!packages/core/src/coverage

cspell.config.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
'node_modules',
1919
'pnpm-lock.yaml',
2020
'LICENSE.md',
21+
'e2e/**',
2122
],
2223
flagWords: banWords,
2324
dictionaries: ['dictionary'],

e2e/projects/coverage.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { dirname, join } from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
import { describe, expect, it } from '@rstest/core';
4+
import fs from 'fs-extra';
5+
import { runRstestCli } from '../scripts';
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = dirname(__filename);
9+
10+
describe('test projects coverage', () => {
11+
it('should run projects correctly with coverage', async () => {
12+
const { cli, expectExecSuccess } = await runRstestCli({
13+
command: 'rstest',
14+
args: ['run', '--globals', '-c', 'rstest.coverage.config.ts'],
15+
options: {
16+
nodeOptions: {
17+
cwd: join(__dirname, 'fixtures'),
18+
},
19+
},
20+
});
21+
22+
await expectExecSuccess();
23+
const logs = cli.stdout.split('\n').filter(Boolean);
24+
25+
expect(
26+
logs.find((log) => log.includes('All files'))?.replaceAll(' ', ''),
27+
).toMatchInlineSnapshot(`"Allfiles|100|100|100|100|"`);
28+
29+
expect(
30+
logs.find((log) => log.includes('client/src'))?.replaceAll(' ', ''),
31+
).toMatchInlineSnapshot(`"client/src|100|100|100|100|"`);
32+
33+
expect(
34+
logs.find(
35+
(log) =>
36+
log.includes('node') &&
37+
log.replaceAll(' ', '').includes('100|100|100|100'),
38+
),
39+
).toBeTruthy();
40+
41+
expect(
42+
fs.existsSync(join(__dirname, 'fixtures/coverage/index.html')),
43+
).toBeTruthy();
44+
});
45+
});

e2e/projects/fixtures/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"private": true,
3+
"name": "@rstest/tests-projects",
4+
"sideEffects": true,
5+
"version": "1.0.0",
6+
"devDependencies": {
7+
"@rstest/core": "workspace:*",
8+
"@rstest/coverage-istanbul": "workspace:*"
9+
}
10+
}

e2e/projects/fixtures/packages/node/test/index.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { sayHi } from '../src/index';
1+
import { sayHi } from '@/src';
22

33
it('should test source code correctly', () => {
44
expect(sayHi()).toBe('hi');
55
});
66

77
it('should can not get document', () => {
8+
// @ts-expect-error
89
expect(global.document).toBeUndefined();
910
});
1011

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"lib": ["ES2020"],
5+
"module": "ESNext",
6+
"strict": true,
7+
"skipLibCheck": true,
8+
"isolatedModules": true,
9+
"resolveJsonModule": true,
10+
"moduleResolution": "bundler",
11+
"useDefineForClassFields": true,
12+
"paths": {
13+
"@/src": ["./src"]
14+
}
15+
},
16+
"include": ["src", "test"]
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from '@rstest/core';
2+
3+
export default defineConfig({
4+
projects: ['packages/*'],
5+
globals: true,
6+
coverage: {
7+
enabled: true,
8+
},
9+
setupFiles: ['./setup.ts'],
10+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { describe, expect, it } from '@rstest/core';
2+
3+
describe('Junit test', () => {
4+
it('should pass', () => {
5+
expect(1 + 1).toBe(2);
6+
});
7+
8+
it('should fail', () => {
9+
expect('hi').toBe('hii');
10+
});
11+
12+
it.skip('should skip', () => {
13+
expect(1 + 1).toBe(3);
14+
});
15+
});

e2e/reporter/junit.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { expect, it } from '@rstest/core';
2+
import { runRstestCli } from '../scripts';
3+
4+
it('junit', async () => {
5+
const { cli, expectLog } = await runRstestCli({
6+
command: 'rstest',
7+
args: ['run', 'junit', '--reporter', 'junit'],
8+
options: {
9+
nodeOptions: {
10+
cwd: __dirname,
11+
},
12+
},
13+
});
14+
15+
await cli.exec;
16+
expect(cli.exec.process?.exitCode).toBe(1);
17+
18+
const logs = cli.stdout.split('\n').filter(Boolean);
19+
20+
expectLog('<?xml version="1.0" encoding="UTF-8"?>', logs);
21+
22+
expectLog('<failure', logs);
23+
expectLog('<skipped/>', logs);
24+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import 'rstest-globals';
2+
3+
it('should run setup correctly', async () => {
4+
expect(process.env.A).toBe('A');
5+
});

0 commit comments

Comments
 (0)