Socket
Socket
Sign inDemoInstall

@testing-library/svelte

Package Overview
Dependencies
Maintainers
15
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@testing-library/svelte - npm Package Compare versions

Comparing version 5.0.1 to 5.1.0

src/vite.js

24

package.json
{
"name": "@testing-library/svelte",
"version": "5.0.1",
"version": "5.1.0",
"description": "Simple and complete Svelte testing utilities that encourage good testing practices.",

@@ -17,2 +17,6 @@ "main": "src/index.js",

"default": "./src/vitest.js"
},
"./vite": {
"types": "./types/vite.d.ts",
"default": "./src/vite.js"
}

@@ -47,4 +51,6 @@ },

"files": [
"src/",
"types/index.d.ts"
"src",
"types",
"!*.test-d.ts",
"!__tests__"
],

@@ -73,4 +79,14 @@ "scripts": {

"peerDependencies": {
"svelte": "^3 || ^4 || ^5"
"svelte": "^3 || ^4 || ^5",
"vite": "*",
"vitest": "*"
},
"peerDependenciesMeta": {
"vite": {
"optional": true
},
"vitest": {
"optional": true
}
},
"dependencies": {

@@ -77,0 +93,0 @@ "@testing-library/dom": "^9.3.1"

@@ -16,3 +16,3 @@ <div align="center">

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

@@ -84,15 +84,38 @@ <!-- prettier-ignore-start -->

## Setup
We recommend using `@testing-library/svelte` with [Vitest][] as your test runner. To get started, add the `svelteTesting` plugin to your Vite or Vitest config.
```diff
// vite.config.js
import { svelte } from '@sveltejs/vite-plugin-svelte'
+ import { svelteTesting } from '@testing-library/svelte/vite'
export default defineConfig({
plugins: [
svelte(),
+ svelteTesting(),
]
});
```
See the [setup docs][] for more detailed setup instructions, including for other test runners like Jest.
[vitest]: https://vitest.dev/
[setup docs]: https://testing-library.com/docs/svelte-testing-library/setup
### Svelte 5 support
If you are riding the bleeding edge of Svelte 5, you'll need to either
import from `@testing-library/svelte/svelte5` instead of `@testing-library/svelte`, or have your `vite.config.js` contains the following alias:
import from `@testing-library/svelte/svelte5` instead of `@testing-library/svelte`, or add an alias to your `vite.config.js`:
```
export default defineConfig(({ }) => ({
```js
export default defineConfig({
plugins: [svelte(), svelteTesting()],
test: {
alias: {
'@testing-library/svelte': '@testing-library/svelte/svelte5'
}
'@testing-library/svelte': '@testing-library/svelte/svelte5',
},
},
}))
})
```

@@ -99,0 +122,0 @@

1

src/__tests__/_vitest-setup.js
import '@testing-library/jest-dom/vitest'
import '../vitest'
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc