Skip to content

Commit 4cd7a7e

Browse files
authored
Merge branch 'main' into fix/missing-context-in-types
2 parents 3379545 + 66c9f45 commit 4cd7a7e

28 files changed

+190
-147
lines changed

.all-contributorsrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@
133133
]
134134
},
135135
{
136-
"login": "ysaskia",
136+
"login": "ysitbon",
137137
"name": "Yoann",
138138
"avatar_url": "https://avatars.githubusercontent.com/u/1370679?v=4",
139-
"profile": "https://github.com/ysaskia",
139+
"profile": "https://github.com/ysitbon",
140140
"contributions": [
141141
"code"
142142
]

.babelrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,19 @@ module.exports = {
33
env: {
44
browser: true,
55
es6: true,
6-
jest: true
6+
'vitest-globals/env': true
77
},
8-
parser: 'babel-eslint',
9-
extends: [
10-
'standard'
11-
],
12-
plugins: [
13-
'svelte3',
14-
'simple-import-sort'
15-
],
8+
extends: ['standard', 'plugin:vitest-globals/recommended'],
9+
plugins: ['svelte', 'simple-import-sort'],
1610
rules: {
1711
'max-len': ['warn', { code: 100 }],
1812
'simple-import-sort/imports': 'error',
19-
'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 2, maxEOF: 0 }]
13+
'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 2, maxEOF: 0 }],
2014
},
2115
overrides: [
22-
{
23-
files: ['**/*.svelte'],
24-
processor: 'svelte3/svelte3'
25-
}
2616
],
2717
parserOptions: {
28-
ecmaVersion: 2019,
29-
sourceType: 'module'
30-
}
18+
ecmaVersion: 2022,
19+
sourceType: 'module',
20+
},
3121
}

.github/dependabot.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "10:00"
8+
open-pull-requests-limit: 10
9+
ignore:
10+
- dependency-name: husky
11+
versions:
12+
- 5.0.9
13+
- 5.1.0
14+
- 5.1.1
15+
- 5.1.2
16+
- 5.1.3
17+
- 5.2.0
18+
- dependency-name: "@commitlint/config-conventional"
19+
versions:
20+
- 12.0.0
21+
- 12.0.1
22+
- dependency-name: "@commitlint/cli"
23+
versions:
24+
- 12.0.0
25+
- 12.0.1

.github/workflows/release.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
if: ${{ !contains(github.head_ref, 'all-contributors') }}
1717
strategy:
1818
matrix:
19-
node: [10, 12, 14, 16]
19+
node: [16, 18, 20]
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: ⬇️ Checkout repo
@@ -41,8 +41,7 @@ jobs:
4141
release:
4242
needs: main
4343
runs-on: ubuntu-latest
44-
if:
45-
${{ github.repository == 'testing-library/svelte-testing-library' &&
44+
if: ${{ github.repository == 'testing-library/svelte-testing-library' &&
4645
contains('refs/heads/main,refs/heads/beta,refs/heads/next,refs/heads/alpha',
4746
github.ref) && github.event_name == 'push' }}
4847
steps:
@@ -59,9 +58,6 @@ jobs:
5958
with:
6059
useLockFile: false
6160

62-
- name: 🏗 Run build script
63-
run: npm run build
64-
6561
- name: 🚀 Release
6662
uses: cycjimmy/semantic-release-action@v2
6763
with:

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
/>
1111
</a>
1212

13-
<p>Simple and complete Svelte testing utilities that encourage good testing
14-
practices.</p>
13+
<p>Simple and complete Svelte testing utilities that encourage good testing practices.</p>
1514

1615
[**Read The Docs**](https://testing-library.com/docs/svelte-testing-library/intro) |
1716
[Edit the docs](https://github.com/alexkrolick/testing-library-docs)

dont-clean-up-after-each.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 34 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
"name": "@testing-library/svelte",
33
"version": "0.0.0-semantically-released",
44
"description": "Simple and complete Svelte testing utilities that encourage good testing practices.",
5-
"main": "dist/index.js",
5+
"exports": {
6+
".": {
7+
"types": "./types/index.d.ts",
8+
"default": "./src/index.js"
9+
}
10+
},
11+
"type": "module",
612
"types": "types/index.d.ts",
713
"license": "MIT",
814
"homepage": "https://github.com/testing-library/svelte-testing-library#readme",
@@ -29,57 +35,50 @@
2935
"e2e"
3036
],
3137
"files": [
32-
"dist",
33-
"dont-cleanup-after-each.js",
34-
"pure.js",
38+
"src/",
3539
"types/index.d.ts"
3640
],
3741
"scripts": {
3842
"toc": "doctoc README.md",
3943
"lint": "eslint src --fix",
40-
"clean": "rimraf dist",
41-
"build": "npm run clean && babel src --out-dir dist --ignore '**/__tests__/**'",
42-
"test": "jest src",
44+
"test": "vitest run src",
4345
"test:watch": "npm run test -- --watch",
4446
"test:update": "npm run test -- --updateSnapshot --coverage",
4547
"setup": "npm install && npm run validate",
46-
"validate": "npm run clean && npm-run-all lint test build",
48+
"validate": "npm-run-all lint test",
4749
"contributors:add": "all-contributors add",
4850
"contributors:generate": "all-contributors generate"
4951
},
5052
"peerDependencies": {
51-
"svelte": "3.x"
53+
"svelte": "^3 || ^4"
5254
},
5355
"dependencies": {
54-
"@testing-library/dom": "^8.1.0"
56+
"@testing-library/dom": "^9.3.1"
5557
},
5658
"devDependencies": {
57-
"@babel/cli": "^7.6.2",
58-
"@babel/core": "^7.6.2",
59-
"@babel/plugin-transform-modules-commonjs": "^7.6.0",
60-
"@babel/preset-env": "^7.6.2",
61-
"@commitlint/cli": "^13.1.0",
62-
"@commitlint/config-conventional": "^13.1.0",
63-
"@testing-library/jest-dom": "^5.0.2",
64-
"@types/jest": "^27.0.0",
65-
"all-contributors-cli": "^6.9.0",
66-
"babel-eslint": "^10.0.3",
67-
"babel-jest": "^27.0.6",
68-
"doctoc": "^2.0.0",
69-
"eslint": "^7.2.0",
70-
"eslint-config-standard": "^16.0.0",
71-
"eslint-plugin-import": "^2.18.2",
72-
"eslint-plugin-node": "^11.0.0",
73-
"eslint-plugin-promise": "^5.1.0",
74-
"eslint-plugin-simple-import-sort": "^7.0.0",
75-
"eslint-plugin-svelte3": "^3.0.0",
76-
"husky": "^7.0.1",
77-
"jest": "^27.0.0",
78-
"lint-staged": "^11.1.1",
59+
"@commitlint/cli": "^17.6.6",
60+
"@commitlint/config-conventional": "^17.6.6",
61+
"@sveltejs/vite-plugin-svelte": "^2.4.2",
62+
"@testing-library/jest-dom": "^5.16.5",
63+
"@vitest/coverage-c8": "^0.33.0",
64+
"all-contributors-cli": "^6.26.0",
65+
"doctoc": "^2.2.1",
66+
"eslint": "^8.43.0",
67+
"eslint-config-standard": "^17.1.0",
68+
"eslint-plugin-import": "^2.27.5",
69+
"eslint-plugin-n": "^16.0.1",
70+
"eslint-plugin-promise": "^6.1.1",
71+
"eslint-plugin-simple-import-sort": "^10.0.0",
72+
"eslint-plugin-svelte": "^2.32.0",
73+
"eslint-plugin-vitest-globals": "^1.3.1",
74+
"husky": "^8.0.3",
75+
"jsdom": "^22.1.0",
76+
"lint-staged": "^13.2.3",
7977
"npm-run-all": "^4.1.5",
80-
"prettier": "^2.0.1",
81-
"svelte": "^3.0.0",
82-
"svelte-jester": "^2.1.4"
78+
"prettier": "^3.0.0",
79+
"svelte": "^4.0.1",
80+
"vite": "^4.3.9",
81+
"vitest": "^0.33.0"
8382
},
8483
"husky": {
8584
"hooks": {
@@ -107,26 +106,5 @@
107106
"extends": [
108107
"@commitlint/config-conventional"
109108
]
110-
},
111-
"jest": {
112-
"testPathIgnorePatterns": [
113-
"src/__tests__/fixtures"
114-
],
115-
"collectCoverageFrom": [
116-
"src/*.js"
117-
],
118-
"setupFilesAfterEnv": [
119-
"@testing-library/jest-dom/extend-expect"
120-
],
121-
"testEnvironment": "jsdom",
122-
"transform": {
123-
"^.+\\.js$": "babel-jest",
124-
"^.+\\.svelte$": "svelte-jester",
125-
"^.+\\.html$": "svelte-jester"
126-
},
127-
"moduleFileExtensions": [
128-
"js",
129-
"svelte"
130-
]
131109
}
132110
}

pure.js

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`auto-cleanup-skip second 1`] = `"<div><h1 data-testid=\\"test\\">Hello world!</h1> <div>we have undefined</div> <button>Button</button></div>"`;
3+
exports[`auto-cleanup-skip > second 1`] = `""`;

src/__tests__/__snapshots__/render.test.js.snap

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`render should accept svelte component options 1`] = `
3+
exports[`render > should accept svelte component options 1`] = `
44
<body>
55
<div>
66
<h1
@@ -18,6 +18,7 @@ exports[`render should accept svelte component options 1`] = `
1818
<button>
1919
Button
2020
</button>
21+
<!--&lt;Comp&gt;-->
2122
<div />
2223
</div>
2324
</body>

src/__tests__/act.test.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { beforeEach, describe, expect, test } from 'vitest'
2+
13
import { act, fireEvent, render as stlRender } from '..'
2-
import Comp from './fixtures/Comp'
4+
import Comp from './fixtures/Comp.svelte'
35

46
describe('act', () => {
57
let props
@@ -36,9 +38,10 @@ describe('act', () => {
3638
})
3739

3840
test('accepts async functions', async () => {
39-
const sleep = (ms) => new Promise(resolve => {
40-
setTimeout(() => resolve(), ms)
41-
})
41+
const sleep = (ms) =>
42+
new Promise((resolve) => {
43+
setTimeout(() => resolve(), ms)
44+
})
4245

4346
const { getByText } = render()
4447
const button = getByText('Button')

src/__tests__/auto-cleanup-skip.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import Comp from './fixtures/Comp'
1+
import { beforeAll, describe, expect, test } from 'vitest'
2+
3+
import Comp from './fixtures/Comp.svelte'
24

35
describe('auto-cleanup-skip', () => {
46
let render
57

6-
beforeAll(() => {
8+
beforeAll(async () => {
79
process.env.STL_SKIP_AUTO_CLEANUP = 'true'
8-
const stl = require('..')
10+
const stl = await import('..')
911
render = stl.render
1012
})
1113

src/__tests__/auto-cleanup.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { describe, expect, test } from 'vitest'
2+
13
import { render } from '..'
2-
import Comp from './fixtures/Comp'
4+
import Comp from './fixtures/Comp.svelte'
35

46
describe('auto-cleanup', () => {
57
// This just verifies that by importing STL in an

src/__tests__/debug.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { prettyDOM } from '@testing-library/dom'
2+
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
23

34
import { render } from '..'
4-
import Comp from './fixtures/Comp'
5+
import Comp from './fixtures/Comp.svelte'
56

67
describe('debug', () => {
78
beforeEach(() => {
8-
jest.spyOn(console, 'log').mockImplementation(() => {})
9+
vi.spyOn(console, 'log').mockImplementation(() => { })
910
})
1011

1112
afterEach(() => {

src/__tests__/events.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { describe, expect, test } from 'vitest'
2+
13
import { fireEvent, render } from '..'
2-
import Comp from './fixtures/Comp'
4+
import Comp from './fixtures/Comp.svelte'
35

46
describe('events', () => {
57
test('state changes are flushed after firing an event', async () => {

src/__tests__/fixtures/Comp.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<svelte:options accessors />
2+
13
<script>
24
import { getContext } from 'svelte'
35
@@ -12,10 +14,10 @@
1214
}
1315
</script>
1416

15-
<style></style>
16-
1717
<h1 data-testid="test">Hello {name}!</h1>
1818

1919
<div>we have {contextName}</div>
2020

2121
<button on:click={handleClick}>{buttonText}</button>
22+
23+
<style></style>

src/__tests__/fixtures/Comp.html renamed to src/__tests__/fixtures/Comp2.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script>
22
export let name
33
4-
let buttonText = "Button Text"
4+
let buttonText = 'Button Text'
55
6-
function handleClick() {
7-
buttonText = "Button Clicked"
6+
function handleClick () {
7+
buttonText = 'Button Clicked'
88
}
99
</script>
1010

0 commit comments

Comments
 (0)