Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix: #35] Enhance documentation around routed tests #39

Merged
merged 1 commit into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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