-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Vitest switch #4687
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
Merged
Merged
Vitest switch #4687
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
62a9b19
Vitest switch
JoviDeCroock 0db9822
Make render work
JoviDeCroock bcd6310
Phewie
JoviDeCroock edf8b79
fix: dedupe preact (#4702)
sheremet-va ee7fbe2
Getting close
JoviDeCroock d90a8a3
All crashes are gone
JoviDeCroock f40709c
One more done
JoviDeCroock 3a8db21
Add babel transform
JoviDeCroock 09f447b
Add coverage
JoviDeCroock 06a9f08
Another try
JoviDeCroock c1e772b
Use vite plugin instead
JoviDeCroock 57bb577
Make all tests pass
JoviDeCroock 49fe0b8
Coverage stuff
JoviDeCroock 4671166
No isolation
JoviDeCroock 63e917e
Add minify option
JoviDeCroock f302778
Format
JoviDeCroock 2b332eb
Fix tests
JoviDeCroock 9784f4b
Remove minify again
JoviDeCroock fa8d8b9
use env var
JoviDeCroock 6780dc4
Reenable useId tests
JoviDeCroock 15b9b87
Remove some deps
JoviDeCroock 96dfa70
Lock terser
JoviDeCroock d0cafb5
Okay vite, lets try 5.16 then jeez
JoviDeCroock fdfaeaf
Add coverage dir
JoviDeCroock b324105
Fix some types
JoviDeCroock e100419
Backport commands
JoviDeCroock 73c1dc8
Make minify work, partially failing 2 tests still
JoviDeCroock 8ee6182
Add lcov
JoviDeCroock 823e8af
change to only
JoviDeCroock 9dbd5df
Maybe
JoviDeCroock ea8bd34
Maybe this?
JoviDeCroock 32a3e9b
Fix some broken test
JoviDeCroock 0c27fa6
Make coverage work
JoviDeCroock 7e2b362
Fix vitest:min
JoviDeCroock 2000037
Add devtools coverage back
JoviDeCroock 556d8a0
Tweak config for consistency
JoviDeCroock e152bf0
test: Copy karma's filter over
rschristian 1c1ab32
Try a cache
JoviDeCroock 3ed298b
Fix test regex
JoviDeCroock fb71e9f
Try a run with isolate false
JoviDeCroock b38f5f2
Bump node and use playwright
JoviDeCroock 473c65b
Restore CI
JoviDeCroock 70e6f1f
Update .github/workflows/build-test.yml
JoviDeCroock ced6160
Switch to webdirver
JoviDeCroock 7eba152
Package json
JoviDeCroock 7651074
Bump vitest
JoviDeCroock 8d64419
Add pending
JoviDeCroock f8ddf37
Skip more files
JoviDeCroock 87eed69
Expand
JoviDeCroock e6a4080
Bump some stuff
JoviDeCroock e7cfb64
bump vitest
JoviDeCroock a2dcfc6
Enable lint
JoviDeCroock 94db9b4
Try some stuff
JoviDeCroock 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 contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,127 @@ | ||
| import { createElement, render } from 'preact'; | ||
| import { | ||
| setupScratch, | ||
| teardown, | ||
| serializeHtml | ||
| } from '../../../test/_util/helpers'; | ||
| import './fakeDevTools'; | ||
| import { resetPropWarnings } from 'preact/debug'; | ||
| import * as PropTypes from 'prop-types'; | ||
| import { jsxDEV as jsxDev } from 'preact/jsx-runtime'; | ||
|
|
||
| describe('PropTypes', () => { | ||
| /** @type {HTMLDivElement} */ | ||
| let scratch; | ||
| let errors = []; | ||
| let warnings = []; | ||
|
|
||
| beforeEach(() => { | ||
| errors = []; | ||
| warnings = []; | ||
| scratch = setupScratch(); | ||
| sinon.stub(console, 'error').callsFake(e => errors.push(e)); | ||
| sinon.stub(console, 'warn').callsFake(w => warnings.push(w)); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| /** @type {*} */ | ||
| console.error.restore(); | ||
| console.warn.restore(); | ||
| teardown(scratch); | ||
| }); | ||
|
|
||
| beforeEach(() => { | ||
| resetPropWarnings(); | ||
| }); | ||
|
|
||
| it("should fail if props don't match prop-types", () => { | ||
| function Foo(props) { | ||
| return jsxDev('h1', { children: props.text }); | ||
| } | ||
|
|
||
| Foo.propTypes = { | ||
| text: PropTypes.string.isRequired | ||
| }; | ||
|
|
||
| render( | ||
| jsxDev( | ||
| Foo, | ||
| { text: 123 }, | ||
| null, | ||
| // @ts-ignore | ||
| false, | ||
| // @ts-ignore | ||
| { fileName: './debug/test/browser/debug.test.js', lineNumber: 41 }, | ||
| // @ts-ignore | ||
| 'self' | ||
| ), | ||
| scratch | ||
| ); | ||
|
|
||
| expect(console.error).to.be.calledOnce; | ||
|
|
||
| // The message here may change when the "prop-types" library is updated, | ||
| // but we check it exactly to make sure all parameters were supplied | ||
| // correctly. | ||
| expect(console.error).to.have.been.calledOnceWith( | ||
| sinon.match( | ||
| /^Failed prop type: Invalid prop `text` of type `number` supplied to `Foo`, expected `string`\.\n {2}in Foo \(at (.*)[/\\]debug[/\\]test[/\\]browser[/\\]debug\.test\.js:[0-9]+\)$/m | ||
| ) | ||
| ); | ||
| }); | ||
|
|
||
| it('should only log a given prop type error once', () => { | ||
| function Foo(props) { | ||
| return jsxDev('h1', { children: props.text }); | ||
| } | ||
|
|
||
| Foo.propTypes = { | ||
| text: PropTypes.string.isRequired, | ||
| count: PropTypes.number | ||
| }; | ||
|
|
||
| // Trigger the same error twice. The error should only be logged | ||
| // once. | ||
| render(jsxDev(Foo, { text: 123 }), scratch); | ||
| render(jsxDev(Foo, { text: 123 }), scratch); | ||
|
|
||
| expect(console.error).to.be.calledOnce; | ||
|
|
||
| // Trigger a different error. This should result in a new log | ||
| // message. | ||
| console.error.resetHistory(); | ||
| render(jsxDev(Foo, { text: 'ok', count: '123' }), scratch); | ||
| expect(console.error).to.be.calledOnce; | ||
| }); | ||
|
|
||
| it('should render with error logged when validator gets signal and throws exception', () => { | ||
| function Baz(props) { | ||
| return jsxDev('h1', { children: props.unhappy }); | ||
| } | ||
|
|
||
| Baz.propTypes = { | ||
| unhappy: function alwaysThrows(obj, key) { | ||
| if (obj[key] === 'signal') throw Error('got prop'); | ||
| } | ||
| }; | ||
|
|
||
| render(jsxDev(Baz, { unhappy: 'signal' }), scratch); | ||
|
|
||
| expect(console.error).to.be.calledOnce; | ||
| expect(errors[0].includes('got prop')).to.equal(true); | ||
| expect(serializeHtml(scratch)).to.equal('<h1>signal</h1>'); | ||
| }); | ||
|
|
||
| it('should not print to console when types are correct', () => { | ||
| function Bar(props) { | ||
| return jsxDev('h1', { children: props.text }); | ||
| } | ||
|
|
||
| Bar.propTypes = { | ||
| text: PropTypes.string.isRequired | ||
| }; | ||
|
|
||
| render(jsxDev(Bar, { text: 'foo' }), scratch); | ||
| expect(console.error).to.not.be.called; | ||
| }); | ||
| }); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.