0.1.0 • Published 4 years ago

svelte-test-register v0.1.0

Weekly downloads
48
License
MIT
Repository
github
Last release
4 years ago

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

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

Usage with Mocha

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

"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:

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

What about Jest?

Jest has a different mechanism for transforming specific files. See 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.