Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ktsn/svelte-jest
Jest Svelte component transformer
https://github.com/ktsn/svelte-jest
jest svelte testing transformer
Last synced: about 2 months 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 (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:33:10.000Z (over 1 year ago)
- Last Synced: 2024-07-06T03:51:37.594Z (3 months ago)
- Topics: jest, svelte, testing, transformer
- Language: JavaScript
- Size: 1.01 MB
- Stars: 37
- Watchers: 3
- Forks: 2
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# svelte-jest
[![Build Status](https://travis-ci.org/ktsn/svelte-jest.svg?branch=master)](https://travis-ci.org/ktsn/svelte-jest)
[![svelte-jest Dev Token](https://badge.devtoken.rocks/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