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)
- Host: GitHub
- URL: https://github.com/dirv/svelte-test-register
- Owner: dirv
- License: mit
- Created: 2019-11-22T18:12:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-30T16:51:49.000Z (almost 2 years ago)
- Last Synced: 2025-08-09T16:53:43.493Z (11 months ago)
- Topics: jasmine, mocha, svelte, testing
- Language: JavaScript
- Size: 13.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# 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.