@testing-library/svelte 4.0.6 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +28 -23
- package/src/__tests__/_vitest-setup.js +2 -0
- package/src/__tests__/context.test.js +14 -0
- package/src/__tests__/fixtures/Context.svelte +7 -0
- package/src/pure.js +3 -4
- package/src/vitest.js +8 -0
- package/types/index.d.ts +2 -3
- package/src/test-setup.js +0 -11
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/svelte",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Simple and complete Svelte testing utilities that encourage good testing practices.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"types": "./types/index.d.ts",
|
|
9
9
|
"default": "./src/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./vitest": {
|
|
12
|
+
"default": "./src/vitest.js"
|
|
10
13
|
}
|
|
11
14
|
},
|
|
12
15
|
"type": "module",
|
|
@@ -41,10 +44,11 @@
|
|
|
41
44
|
],
|
|
42
45
|
"scripts": {
|
|
43
46
|
"toc": "doctoc README.md",
|
|
44
|
-
"lint": "
|
|
45
|
-
"
|
|
46
|
-
"test
|
|
47
|
-
"test:
|
|
47
|
+
"lint": "(prettier . --check || true) && eslint .",
|
|
48
|
+
"format": "prettier . --write && eslint . --fix",
|
|
49
|
+
"test": "vitest run --coverage",
|
|
50
|
+
"test:watch": "vitest",
|
|
51
|
+
"test:update": "vitest run --update",
|
|
48
52
|
"setup": "npm install && npm run validate",
|
|
49
53
|
"validate": "npm-run-all lint test",
|
|
50
54
|
"contributors:add": "all-contributors add",
|
|
@@ -60,11 +64,14 @@
|
|
|
60
64
|
"@commitlint/cli": "^17.6.6",
|
|
61
65
|
"@commitlint/config-conventional": "^17.6.6",
|
|
62
66
|
"@sveltejs/vite-plugin-svelte": "^2.4.2",
|
|
63
|
-
"@testing-library/jest-dom": "^
|
|
64
|
-
"@
|
|
67
|
+
"@testing-library/jest-dom": "^6.3.0",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^6.19.1",
|
|
69
|
+
"@typescript-eslint/parser": "^6.19.1",
|
|
70
|
+
"@vitest/coverage-v8": "^0.33.0",
|
|
65
71
|
"all-contributors-cli": "^6.26.0",
|
|
66
72
|
"doctoc": "^2.2.1",
|
|
67
73
|
"eslint": "^8.43.0",
|
|
74
|
+
"eslint-config-prettier": "^9.1.0",
|
|
68
75
|
"eslint-config-standard": "^17.1.0",
|
|
69
76
|
"eslint-plugin-import": "^2.27.5",
|
|
70
77
|
"eslint-plugin-n": "^16.0.1",
|
|
@@ -77,30 +84,28 @@
|
|
|
77
84
|
"lint-staged": "^13.2.3",
|
|
78
85
|
"npm-run-all": "^4.1.5",
|
|
79
86
|
"prettier": "^3.0.0",
|
|
87
|
+
"prettier-plugin-svelte": "^3.1.2",
|
|
80
88
|
"svelte": "^4.0.1",
|
|
89
|
+
"svelte-jester": "^3.0.0",
|
|
90
|
+
"typescript": "^5.3.3",
|
|
81
91
|
"vite": "^4.3.9",
|
|
82
92
|
"vitest": "^0.33.0"
|
|
83
93
|
},
|
|
84
|
-
"husky": {
|
|
85
|
-
"hooks": {
|
|
86
|
-
"pre-commit": "lint-staged",
|
|
87
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
94
|
"lint-staged": {
|
|
91
|
-
"README.md": [
|
|
95
|
+
"{README.md,.all-contributorsrc}": [
|
|
92
96
|
"npm run toc",
|
|
93
|
-
"prettier --parser markdown --write",
|
|
94
|
-
"git add"
|
|
95
|
-
],
|
|
96
|
-
".all-contributorsrc": [
|
|
97
97
|
"npm run contributors:generate",
|
|
98
|
-
"
|
|
98
|
+
"npx --no-install prettier --write README.md .all-contributorsrc",
|
|
99
|
+
"git add README.md .all-contributorsrc"
|
|
100
|
+
],
|
|
101
|
+
"src/**/*": [
|
|
102
|
+
"npx --no-install vitest related --run"
|
|
103
|
+
],
|
|
104
|
+
"*.{js,cjs,ts,svelte,json,yml,yaml}": [
|
|
105
|
+
"npx --no-install prettier --check"
|
|
99
106
|
],
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"npm test",
|
|
103
|
-
"git add"
|
|
107
|
+
"*.{js,cjs,ts,svelte}": [
|
|
108
|
+
"npx --no-install eslint"
|
|
104
109
|
]
|
|
105
110
|
},
|
|
106
111
|
"commitlint": {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { expect, test } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { render } from '..'
|
|
4
|
+
import Comp from './fixtures/Context.svelte'
|
|
5
|
+
|
|
6
|
+
test('can set a context', () => {
|
|
7
|
+
const message = 'Got it'
|
|
8
|
+
|
|
9
|
+
const { getByText } = render(Comp, {
|
|
10
|
+
context: new Map(Object.entries({ foo: { message } })),
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
expect(getByText(message)).toBeTruthy()
|
|
14
|
+
})
|
package/src/pure.js
CHANGED
|
@@ -109,10 +109,9 @@ const cleanup = () => {
|
|
|
109
109
|
Array.from(containerCache.keys()).forEach(cleanupAtContainer)
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
const act = (fn) => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return value.then(() => tick())
|
|
112
|
+
const act = async (fn) => {
|
|
113
|
+
if (fn) {
|
|
114
|
+
await fn()
|
|
116
115
|
}
|
|
117
116
|
return tick()
|
|
118
117
|
}
|
package/src/vitest.js
ADDED
package/types/index.d.ts
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
// Project: https://github.com/testing-library/svelte-testing-library
|
|
3
3
|
// Definitions by: Rahim Alwer <https://github.com/mihar-22>
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { SvelteComponent, ComponentProps, ComponentConstructorOptions } from 'svelte'
|
|
5
|
+
import {BoundFunction, EventType,Queries, queries} from '@testing-library/dom'
|
|
6
|
+
import { ComponentConstructorOptions,ComponentProps, SvelteComponent } from 'svelte'
|
|
8
7
|
|
|
9
8
|
export * from '@testing-library/dom'
|
|
10
9
|
|
package/src/test-setup.js
DELETED