-
Notifications
You must be signed in to change notification settings - Fork 11
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
Migrate from jest to vitest (wip) #92
Draft
ayushmanchhabra
wants to merge
32
commits into
main
Choose a base branch
from
dev-82
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
48acce5
chore(deps): install vitest
ayushmanchhabra b18f5b6
chore(ci): upgrade github actions
ayushmanchhabra 1b69e1e
chore(ci): use Node v18.7.0
ayushmanchhabra 123c37f
fix(ci): resolve syntax error
ayushmanchhabra 237f8b8
chore: use Node v18.20.3
ayushmanchhabra 3682301
chore(test): migrate tests from jest to vitest
ayushmanchhabra 7fcf412
chore(ci): use volta action to get old node versions
ayushmanchhabra ce4703e
chore(test): port jest mocks to vitest
ayushmanchhabra d650af5
chore(ci): pin node versions using volta
ayushmanchhabra 80ddf84
fix(ci): resolve syntax error
ayushmanchhabra 63d96cf
chore(ci): cancel in progress jobs
ayushmanchhabra ba038db
fix(ci): resolve syntax error
ayushmanchhabra 374456d
chore(ci): add back some deleted config
ayushmanchhabra fe9c552
chore(ci): node 18.20.3 -> 18.x
ayushmanchhabra ff48fdd
fix(ci): npm -v on Node 18 only
ayushmanchhabra 4e83e86
chore(ci): node 8 -> 8.3.0
ayushmanchhabra 8186509
chore(eslint): add back tjw-jest
ayushmanchhabra 4df6457
chore(vite): remove timeout config
ayushmanchhabra 294439d
chore(vitest): enable global apis
ayushmanchhabra f10dcd8
chore(jest): remove jest workaround comment
ayushmanchhabra 62957ef
chore: revert to original module import style
ayushmanchhabra 91c9bbd
Merge branch 'dev-82' of github.com:nwutils/create-desktop-shortcuts …
ayushmanchhabra 2f480e5
chore(ci): volta pin npm version for Node 8
ayushmanchhabra 95b962a
chore(vitest): mock some node modules
ayushmanchhabra 2fc245f
chore(vitest): misc changes
ayushmanchhabra 6f7300c
chore(deps): update lock file
ayushmanchhabra b17cf2e
chore(vitest): mock node:os
ayushmanchhabra ddda8da
chore(test): helper test suite passes
ayushmanchhabra 8e05557
chore(test): jest -> vi
ayushmanchhabra 68f490d
Merge branch 'dev-82' of github.com:nwutils/create-desktop-shortcuts …
ayushmanchhabra 969fdf9
Merge branch 'main' into dev-82
ayushmanchhabra 8d9e777
chore: revert some things
ayushmanchhabra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
/** | ||
* @file The global setup for all Jest tests. | ||
* @file The global setup for all Vitest tests. | ||
* @author TheJaredWilcurt | ||
*/ | ||
|
||
const os = require('os'); | ||
const processPlatform = process.platform; | ||
const testHelpers = require('@@/testHelpers.js'); | ||
import process from 'process'; | ||
import os from 'os'; | ||
import testHelpers from '@@/testHelpers.js'; | ||
|
||
if (os.platform() !== 'win32') { | ||
testHelpers.mockOsType(); | ||
} | ||
|
||
global.beforeEach(() => { | ||
beforeEach(() => { | ||
vi.spyOn(os, 'homedir').mockReturnValue(process.platform === 'win32' ? 'C:\\Users\\DUMMY': '/home/DUMMY'); | ||
}); | ||
|
||
global.afterEach(() => { | ||
testHelpers.mockPlatform(processPlatform); | ||
jest.resetModules(); | ||
// thing = jest.fn(); gets called, then .toHaveBeenCalledWith() will see all calls, but this clears the log after each test | ||
jest.clearAllMocks(); | ||
afterEach(() => { | ||
testHelpers.mockPlatform(process.platform); | ||
vi.resetModules(); | ||
// thing = vi.fn(); gets called, then .toHaveBeenCalledWith() will see all calls, but this clears the log after each test | ||
vi.clearAllMocks(); | ||
vi.restoreAllMocks(); | ||
}); | ||
|
||
// Jest's setTimeout defaults to 5 seconds. | ||
// Bump the timeout to 60 seconds. | ||
jest.setTimeout(60 * 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { fileURLToPath, URL } from 'url'; | ||
|
||
import { defineConfig } from 'vitest/config' | ||
|
||
export default defineConfig | ||
({ | ||
resolve: { | ||
alias: { | ||
'@': fileURLToPath(new URL('./src', import.meta.url)), | ||
'@@': fileURLToPath(new URL('./tests', import.meta.url)), | ||
} | ||
}, | ||
test: { | ||
coverage: { | ||
provider: 'v8', | ||
}, | ||
globals: true, | ||
setupFiles: './tests/setup.js', | ||
}, | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was related to this, where we mock out the OS module to fake which OS we are on for certain tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some modules are mocked successfully while others aren't such as node:os - will look into it when I get time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I mocked out one way of checking the OS/platform, and exclusively used that way of checking for it in the library. That way I could pretend to be a different OS in the tests. But also I still needed a way to check the real OS that was running the tests, because it would have different behavior and the tests still needed to pass on all real OS's. So I used a different way to check the real OS that wasn't mocked. I think that's what was going on with
process.platform
vsrequire('os').platform()
.