Skip to content

Commit

Permalink
[bugfix: #35] Enhance documentation around routed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rossyman committed Jul 25, 2022
1 parent b78d96e commit 0ae81c2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
33 changes: 26 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This is an **experimental** command to run to add Jest to your SvelteKit project
You must start with a fresh copy of the official SvelteKit template, which is currently created by running this command:

```sh
npm init svelte@next
npm create svelte@latest <app-name>
```

Once that is set up, run this command in your project directory to set up Jest:
Expand Down Expand Up @@ -38,21 +38,40 @@ After the preset runs,

### πŸ“‘ Relevant Documentation

- [Svelte Testing Library Docs](https://testing-library.com/docs/svelte-testing-library/intro/)
- [Jest DOM](https://github.com/testing-library/jest-dom#usage)
- [Jest](https://jestjs.io)
- [Svelte Testing Library Docs](https://testing-library.com/docs/svelte-testing-library/intro/)
- [Jest DOM](https://github.com/testing-library/jest-dom#usage)
- [Jest](https://jestjs.io)

## Routed Tests

If you run into an issue when writing tests for routed svelte components or files (`Reference error: describe is not defined`), this is a known issue. To fix it, you must modify your `svelte.config.js` (Specifically the `routes` property) with the following modification:
```js
kit: {
// Prior svelte configuration goes here...
routes: filepath => {
return ![
// Exclude spec files
/\.spec\.(ts|js)$/,
// Original routes
/(?:(?:^_|\/_)|(?:^\.|\/\.)(?!well-known))/,
].some(regex => regex.test(filepath))
},
}
```

The reason we cannot perform this change directly for you, is due to a limitation within [Preset](https://usepreset.dev/).

### 😡 Help! I have a question
## 😡 Help! I have a question

[Create an issue](https://github.com/svelte-add/jest/issues/new) and we'll try to help.

### 😑 Fix! There is something that needs improvement
## 😑 Fix! There is something that needs improvement

[Create an issue](https://github.com/rossyman/svelte-add-jest/issues/new) or [pull request](https://github.com/rossyman/svelte-add-jest/pulls) and we'll try to fix.

These are new tools, so there are likely to be problems in this project. Thank you for bringing them to our attention or fixing them for us.

## πŸ“„ License
# πŸ“„ License

MIT

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@rossyman/svelte-add-jest",
"version": "1.3.3",
"version": "1.3.4",
"description": "SvelteKit adder for Jest unit testing",
"license": "MIT",
"keywords": [
Expand Down

0 comments on commit 0ae81c2

Please sign in to comment.