Skip to content

Commit 3ef300b

Browse files
committed
test: extract tests directory out of src
1 parent b2005b7 commit 3ef300b

32 files changed

+25
-31
lines changed

jest.config.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@ const SVELTE_TRANSFORM_PATTERN =
44
SVELTE_VERSION >= '5' ? '^.+\\.svelte(?:\\.js)?$' : '^.+\\.svelte$'
55

66
export default {
7-
testMatch: ['<rootDir>/src/__tests__/**/*.test.js'],
7+
testMatch: ['<rootDir>/tests/**/*.test.js'],
88
transform: {
99
[SVELTE_TRANSFORM_PATTERN]: 'svelte-jester',
1010
},
1111
moduleFileExtensions: ['js', 'svelte'],
1212
extensionsToTreatAsEsm: ['.svelte'],
1313
testEnvironment: 'jsdom',
14-
setupFilesAfterEnv: ['<rootDir>/src/__tests__/_jest-setup.js'],
14+
setupFilesAfterEnv: ['<rootDir>/tests/_jest-setup.js'],
1515
injectGlobals: false,
1616
moduleNameMapper: {
17-
'^vitest$': '<rootDir>/src/__tests__/_jest-vitest-alias.js',
17+
'^vitest$': '<rootDir>/tests/_jest-vitest-alias.js',
1818
},
1919
resetMocks: true,
2020
restoreMocks: true,
2121
collectCoverageFrom: ['<rootDir>/src/**/*'],
2222
coveragePathIgnorePatterns: [
23-
'/__tests__/',
2423
'<rootDir>/src/vite.js',
2524
'<rootDir>/src/vitest.js',
2625
],

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
],
5050
"files": [
5151
"src",
52-
"types",
53-
"!__tests__"
52+
"types"
5453
],
5554
"scripts": {
5655
"all": "npm-run-all contributors:generate toc format types build test:vitest:* test:jest",
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/__tests__/auto-cleanup.test.js renamed to tests/auto-cleanup.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
22

3-
import { IS_JEST } from './utils.js'
3+
import { IS_JEST } from './_env.js'
44

55
// TODO(mcous, 2024-12-08): clearing module cache and re-importing
66
// in Jest breaks Svelte's environment checking heuristics.
@@ -19,7 +19,7 @@ describe.skipIf(IS_JEST)('auto-cleanup', () => {
1919
})
2020

2121
test('calls afterEach with cleanup if globally defined', async () => {
22-
const { render } = await import('../index.js')
22+
const { render } = await import('@testing-library/svelte')
2323

2424
expect(globalAfterEach).toHaveBeenCalledTimes(1)
2525
expect(globalAfterEach).toHaveBeenLastCalledWith(expect.any(Function))
@@ -35,7 +35,7 @@ describe.skipIf(IS_JEST)('auto-cleanup', () => {
3535
test('does not call afterEach if process STL_SKIP_AUTO_CLEANUP is set', async () => {
3636
process.env.STL_SKIP_AUTO_CLEANUP = 'true'
3737

38-
await import('../index.js')
38+
await import('@testing-library/svelte')
3939

4040
expect(globalAfterEach).toHaveBeenCalledTimes(0)
4141
})
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)