Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ea37c47

Browse files
authored
test: extract tests directory out of src (#433)
1 parent b2005b7 commit ea37c47

32 files changed

+29
-27
lines changed

‎jest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ 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',
18+
'^@testing-library\\/svelte$': '<rootDir>/src/index.js',
1819
},
1920
resetMocks: true,
2021
restoreMocks: true,
2122
collectCoverageFrom: ['<rootDir>/src/**/*'],
2223
coveragePathIgnorePatterns: [
23-
'/__tests__/',
2424
'<rootDir>/src/vite.js',
2525
'<rootDir>/src/vitest.js',
2626
],

‎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)

AltStyle によって変換されたページ (->オリジナル) /