-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Added Option to Automatically Add Vitest to New Projects using svelte-create #5708
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
Changes from 13 commits
2a35dd1
09d4ef3
5fa5ec0
e4e9ccf
1bf7c59
fdd3fcd
e75378f
a168514
e9e38a6
2f97dee
8c451fe
e48c02f
f59f9c0
0a8fc37
b512b49
691e874
78149b5
c06a74f
db95545
e670e29
e71e21a
658dd56
8d3d11d
01ab4ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'create-svelte': patch | ||
| --- | ||
|
|
||
| Added the option to add Vitest to new projects |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "extends": "./.svelte-kit/tsconfig.json", | ||
| "compilerOptions": { | ||
| "types": ["vitest/globals"], | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "skipLibCheck": true, | ||
| "sourceMap": true, | ||
| "strict": true | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "extends": "./.svelte-kit/tsconfig.json", | ||
| "compilerOptions": { | ||
| "types": ["vitest/globals"], | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "skipLibCheck": true, | ||
| "sourceMap": true, | ||
| "strict": true | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "devDependencies": { | ||
| "vitest": "^0.19.1" | ||
| }, | ||
| "scripts": { | ||
| "test:unit": "vitest" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { sum } from './sum'; | ||
|
benmccann marked this conversation as resolved.
Outdated
|
||
|
|
||
| describe('sum test', () => { | ||
| it('adds 1 + 2 to equal 3', () => { | ||
| expect(sum(1, 2)).toBe(3); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /** | ||
| * Add two numbers | ||
| * @param {number} a | ||
| * @param {number} b | ||
| */ | ||
| export function sum(a: number, b: number): number { | ||
|
benmccann marked this conversation as resolved.
Outdated
|
||
| return a + b; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { sveltekit } from '@sveltejs/kit/vite'; | ||
|
|
||
| /** @type {import('vite').UserConfig} */ | ||
| const config = { | ||
| plugins: [sveltekit()], | ||
| test: { | ||
| include: ['src/**/*.{test}.{js,ts}'], | ||
|
benmccann marked this conversation as resolved.
Outdated
benmccann marked this conversation as resolved.
Outdated
|
||
| globals: true | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another discussion ;) globals: true would mean we'd have to also provide additional env typing for the test files, just leave it off and resort to imports? It's cleaner anyways
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, just gonna admit that a lot of my decisions, have been based off what I've seen other people doing, and what my team has been doing. I took a lot of inspiration from @davipon on his add vitest library I have yet to see someone not use globals I think because having to add them for every single test starts to get annoying, adding the imports just becomes repetitive boilerplate after a while. Definitely a preference though, the script already adds the vitest types to the tsconfig or Jsconfig based on what you choose. |
||
| } | ||
| }; | ||
|
|
||
| export default config; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { sveltekit } from '@sveltejs/kit/vite'; | ||
|
|
||
| /** @type {import('vite').UserConfig} */ | ||
| const config = { | ||
| plugins: [sveltekit()] | ||
| }; | ||
|
|
||
| export default config; |
Uh oh!
There was an error while loading. Please reload this page.