Miss any of our Open RFC calls?Watch the recordings here! »

svelte-jest

0.3.1 • Public • Published

svelte-jest

Build Status svelte-jest Dev Token

Jest Svelte component transformer.

Usage

Install it via npm:

$ npm install -D svelte-jest

Add Jest configuration:

{
  "jest": {
    "transform": {
      "\\.js$": "babel-jest",
      "\\.svelte$": "svelte-jest"
    },
    "moduleFileExtensions": [
      "js",
      "json",
      "svelte"
    ]
  }
}

Then you import your Svelte component in your test code:

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

Install

npm i svelte-jest

DownloadsWeekly Downloads

4,113

Version

0.3.1

License

MIT

Unpacked Size

3.68 kB

Total Files

4

Last publish

Collaborators

  • avatar