An open API service indexing awesome lists of open source software.

https://github.com/dirv/svelte-test-register

Compile imported Svelte 3 components on Node (e.g. for test runners like Mocha and Jasmine)
https://github.com/dirv/svelte-test-register

jasmine mocha svelte testing

Last synced: 4 months ago
JSON representation

Compile imported Svelte 3 components on Node (e.g. for test runners like Mocha and Jasmine)

Awesome Lists containing this project

README

          



npm version


install size


build status


license

# svelte-test-register

If you're using Mocha or Jasmine to run tests against Svelte components, you'll need to configure Node to compile your `.svelte` files. That's what this script does. It registers Svelte compilation outside of the production Rollup build process.

It also installs source map support so that stack traces map back to the original `.svelte` file.

## Installation

```bash
npm install --save-dev svelte-test-register
```

## Usage with Mocha

In `package.json`, update the Mocha script entry to require `svelte-test-register`:

```json
"scripts": {
"mocha": "mocha --require svelte-test-register"
}
```

## Usage with Jasmine

In `spec/support/jasmine.json`, update the helpers section to include the `index.js` from the `svelt-test-register` package:

```json
"helpers": [
"../node_modules/svelte-test-register/index.js"
]
```

## What about Jest?

Jest has a different mechanism for transforming specific files. See [jest-transform-svelte](https://github.com/rspieker/jest-transform-svelte) if you'd like to test Svelte components in Jest.

## Known issues

Source map support does not yet work in Jasmine.

## Contributing

All contributions are welcome. Please feel free to create issues or raise PRs.