https://github.com/ktsn/svelte-jest
Jest Svelte component transformer
https://github.com/ktsn/svelte-jest
jest svelte testing transformer
Last synced: about 1 month ago
JSON representation
Jest Svelte component transformer
- Host: GitHub
- URL: https://github.com/ktsn/svelte-jest
- Owner: ktsn
- License: mit
- Created: 2018-03-23T14:22:13.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:33:10.000Z (over 2 years ago)
- Last Synced: 2025-03-26T08:11:20.882Z (about 2 months ago)
- Topics: jest, svelte, testing, transformer
- Language: JavaScript
- Size: 1.01 MB
- Stars: 36
- Watchers: 2
- Forks: 2
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# svelte-jest
[](https://travis-ci.org/ktsn/svelte-jest)
[](https://devtoken.rocks/package/svelte-jest)Jest Svelte component transformer.
## Usage
Install it via npm:
```sh
$ npm install -D svelte-jest
```Add Jest configuration:
```js
{
"jest": {
"transform": {
"\\.js$": "babel-jest",
"\\.svelte$": "svelte-jest"
},
"moduleFileExtensions": [
"js",
"json",
"svelte"
]
}
}
```Then you import your Svelte component in your test code:
```js
import Foo from '../components/Foo.svelte'describe('Foo Component', () => {
it('should render', () => {
const el = document.createElement('div')
new Foo({
target: el
})
expect(el.textContent).toBe('Hello Foo!')
})
})
```## License
MIT