Repository navigation
test: run messenger on Vitest #10869
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 all commits
96ed564
3345d9c
1144493
b5e213e
88302da
6410b57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||
| import { describe, expect, test } from 'tstyche'; | ||||||||||
| import { describe, test } from 'vitest'; | ||||||||||
|
|
||||||||||
| import { Messenger } from './Messenger.js'; | ||||||||||
|
|
||||||||||
|
|
@@ -28,13 +28,13 @@ describe('Messenger', () => { | |||||||||
| EventA | EventB | ||||||||||
| >({ namespace: 'Child' }); | ||||||||||
|
|
||||||||||
| expect( | ||||||||||
| source.delegateAll({ | ||||||||||
| messenger: child, | ||||||||||
| actions: ['A:getValue', 'B:getName'], | ||||||||||
| events: ['A:stateChange', 'B:nameChange'], | ||||||||||
| }), | ||||||||||
| ).type.not.toRaiseError(); | ||||||||||
| // We purposely make no assertions here; | ||||||||||
| // this test file will fail if there are type errors. | ||||||||||
| source.delegateAll({ | ||||||||||
|
Collaborator
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. Should we add a comment here that if this test fails, there are type errors?
Suggested change
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. Makes sense! I left this comment #10869 (comment) for reviewers so that they check that this is the documented way. I had the same thought, as it wasn't immediately clear to me either what behavior to expect. I guess we'll just need to get more familiar with how Vitest handles type checking in tests.
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. Added here 6410b57 |
||||||||||
| messenger: child, | ||||||||||
| actions: ['A:getValue', 'B:getName'], | ||||||||||
| events: ['A:stateChange', 'B:nameChange'], | ||||||||||
| }); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| test('excludes the delegatee own-namespace actions from the exhaustiveness check', () => { | ||||||||||
|
|
@@ -45,13 +45,13 @@ describe('Messenger', () => { | |||||||||
| namespace: 'Child', | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| expect( | ||||||||||
| source.delegateAll({ | ||||||||||
| messenger: child, | ||||||||||
| actions: ['A:getValue'], | ||||||||||
| events: [], | ||||||||||
| }), | ||||||||||
| ).type.not.toRaiseError(); | ||||||||||
| // We purposely make no assertions here; | ||||||||||
| // this test file will fail if there are type errors. | ||||||||||
| source.delegateAll({ | ||||||||||
|
Collaborator
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.
Suggested change
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. Added here 6410b57 |
||||||||||
| messenger: child, | ||||||||||
| actions: ['A:getValue'], | ||||||||||
| events: [], | ||||||||||
| }); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| test('raises a type error when an external action is missing', () => { | ||||||||||
|
|
@@ -62,13 +62,12 @@ describe('Messenger', () => { | |||||||||
| namespace: 'Child', | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| expect( | ||||||||||
| source.delegateAll({ | ||||||||||
| messenger: child, | ||||||||||
| actions: ['A:getValue'], | ||||||||||
| events: [], | ||||||||||
| }), | ||||||||||
| ).type.toRaiseError(); | ||||||||||
| source.delegateAll({ | ||||||||||
| messenger: child, | ||||||||||
| // @ts-expect-error The external action `B:getName` is missing. | ||||||||||
| actions: ['A:getValue'], | ||||||||||
| events: [], | ||||||||||
| }); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| test('raises a type error when an external event is missing', () => { | ||||||||||
|
|
@@ -79,13 +78,12 @@ describe('Messenger', () => { | |||||||||
| namespace: 'Child', | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| expect( | ||||||||||
| source.delegateAll({ | ||||||||||
| messenger: child, | ||||||||||
| actions: [], | ||||||||||
| events: ['A:stateChange'], | ||||||||||
| }), | ||||||||||
| ).type.toRaiseError(); | ||||||||||
| source.delegateAll({ | ||||||||||
| messenger: child, | ||||||||||
| actions: [], | ||||||||||
| // @ts-expect-error The external event `B:nameChange` is missing. | ||||||||||
| events: ['A:stateChange'], | ||||||||||
| }); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| test('raises a type error when the source cannot provide a required external action', () => { | ||||||||||
|
|
@@ -96,13 +94,12 @@ describe('Messenger', () => { | |||||||||
| namespace: 'Child', | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| expect( | ||||||||||
| source.delegateAll({ | ||||||||||
| messenger: child, | ||||||||||
| actions: ['A:getValue'], | ||||||||||
| events: [], | ||||||||||
| }), | ||||||||||
| ).type.toRaiseError(); | ||||||||||
| source.delegateAll({ | ||||||||||
| messenger: child, | ||||||||||
| // @ts-expect-error The source cannot provide `B:getName`. | ||||||||||
| actions: ['A:getValue'], | ||||||||||
| events: [], | ||||||||||
| }); | ||||||||||
| }); | ||||||||||
| }); | ||||||||||
| }); | ||||||||||
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.
https://vitest.dev/guide/testing-types