diff --git a/e2e/rootDir/fixtures/index.test.ts b/e2e/rootDir/fixtures/index.test.ts new file mode 100644 index 000000000..60a24d39d --- /dev/null +++ b/e2e/rootDir/fixtures/index.test.ts @@ -0,0 +1,7 @@ +import { describe, expect, it } from '@rstest/core'; + +describe('Index', () => { + it('should add two numbers correctly', () => { + expect(1 + 1).toBe(2); + }); +}); diff --git a/e2e/rootDir/fixtures/index1.test.ts b/e2e/rootDir/fixtures/index1.test.ts new file mode 100644 index 000000000..4fca44ec8 --- /dev/null +++ b/e2e/rootDir/fixtures/index1.test.ts @@ -0,0 +1,7 @@ +import { describe, expect, it } from '@rstest/core'; + +describe('Index1', () => { + it('should add two numbers correctly', () => { + expect(1 + 1).toBe(2); + }); +}); diff --git a/e2e/rootDir/fixtures/rstest.config.ts b/e2e/rootDir/fixtures/rstest.config.ts new file mode 100644 index 000000000..11fe56892 --- /dev/null +++ b/e2e/rootDir/fixtures/rstest.config.ts @@ -0,0 +1,6 @@ +import { defineConfig } from '@rstest/core'; + +export default defineConfig({ + include: ['/**/*.test.ts'], + exclude: ['/tests/index1.test.ts'], +}); diff --git a/e2e/rootDir/fixtures/tests/index.test.ts b/e2e/rootDir/fixtures/tests/index.test.ts new file mode 100644 index 000000000..60a24d39d --- /dev/null +++ b/e2e/rootDir/fixtures/tests/index.test.ts @@ -0,0 +1,7 @@ +import { describe, expect, it } from '@rstest/core'; + +describe('Index', () => { + it('should add two numbers correctly', () => { + expect(1 + 1).toBe(2); + }); +}); diff --git a/e2e/rootDir/fixtures/tests/index1.test.ts b/e2e/rootDir/fixtures/tests/index1.test.ts new file mode 100644 index 000000000..4fca44ec8 --- /dev/null +++ b/e2e/rootDir/fixtures/tests/index1.test.ts @@ -0,0 +1,7 @@ +import { describe, expect, it } from '@rstest/core'; + +describe('Index1', () => { + it('should add two numbers correctly', () => { + expect(1 + 1).toBe(2); + }); +}); diff --git a/e2e/rootDir/index.test.ts b/e2e/rootDir/index.test.ts new file mode 100644 index 000000000..d7b6b7754 --- /dev/null +++ b/e2e/rootDir/index.test.ts @@ -0,0 +1,29 @@ +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { describe, it } from '@rstest/core'; +import { runRstestCli } from '../scripts/'; + +const __filename = fileURLToPath(import.meta.url); + +const __dirname = dirname(__filename); + +describe('test ', () => { + it('should match files correctly with ', async ({ + onTestFinished, + }) => { + const { expectExecSuccess, expectLog } = await runRstestCli({ + command: 'rstest', + args: ['run'], + onTestFinished, + options: { + nodeOptions: { + cwd: join(__dirname, 'fixtures'), + }, + }, + }); + + await expectExecSuccess(); + + expectLog('Test Files 3 passed'); + }); +}); diff --git a/packages/core/src/utils/helper.ts b/packages/core/src/utils/helper.ts index 9950e05b0..fe6cb13a2 100644 --- a/packages/core/src/utils/helper.ts +++ b/packages/core/src/utils/helper.ts @@ -1,10 +1,10 @@ -import { isAbsolute, join, parse, sep } from 'pathe'; +import { isAbsolute, join, normalize, parse, sep } from 'pathe'; import color from 'picocolors'; import type { RuntimeConfig, TestResult } from '../types'; import { TEST_DELIMITER } from './constants'; export const formatRootStr = (rootStr: string, root: string): string => { - return rootStr.replace('', root); + return rootStr.replace('', normalize(root)); }; export function getAbsolutePath(base: string, filepath: string): string {