Skip to content
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
8 changes: 3 additions & 5 deletions oxlint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3665,17 +3665,15 @@
"count": 1
}
},
"packages/messenger/jest.config.cjs": {
"import/unambiguous": {
"count": 1
}
},
"packages/messenger/src/Messenger.test.ts": {
"typescript/no-unsafe-member-access": {
"count": 12
},
"typescript/no-unsafe-return": {
"count": 12
},
"vitest/no-conditional-in-test": {
"count": 3
}
},
"packages/messenger/src/Messenger.ts": {
Expand Down
29 changes: 0 additions & 29 deletions packages/messenger/jest.config.cjs

This file was deleted.

19 changes: 6 additions & 13 deletions packages/messenger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,21 @@
"lint:tsconfigs": "node --import ../../scripts/resolver/register.ts --experimental-transform-types ../../scripts/lint-tsconfigs/lint-tsconfigs.ts",
"lint:tsconfigs:fix": "node --import ../../scripts/resolver/register.ts --experimental-transform-types ../../scripts/lint-tsconfigs/lint-tsconfigs.ts --fix",
"since-latest-release": "../../scripts/since-latest-release.sh",
"test": "yarn test:unit && yarn test:types",
"test:clean": "yarn test:unit:clean && yarn test:types",
"test:types": "tstyche",
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
"test:unit:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
"test:unit:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
"test:verbose": "yarn test:unit:verbose && yarn test:types",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
"test": "vitest",
"test:clean": "vitest --clearCache",
"test:verbose": "vitest --reporter=verbose",
"test:watch": "vitest --watch"
},
"devDependencies": {
"@metamask/auto-changelog": "^6.2.1",
"@types/jest": "^30.0.0",
"@typescript/native": "npm:typescript@^7.0.2",
"deepmerge": "^4.3.1",
"immer": "^11.1.18",
"jest": "^30.5.2",
"rimraf": "^6.1.3",
"ts-jest": "^29.4.14",
"tstyche": "^7.2.5",
"typedoc": "^0.28.20",
"typedoc-plugin-missing-exports": "^4.1.4",
"typescript": "npm:@typescript/typescript6@^6.0.2"
"typescript": "npm:@typescript/typescript6@^6.0.2",
"vitest": "^5.0.0"
},
"peerDependencies": {
"typescript": ">=5.0.0"
Expand Down

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';

Expand Down Expand Up @@ -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({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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
source.delegateAll({
// We purposely make no assertions here;
// this test file will fail if there are type errors.
source.delegateAll({

@cryptodev-2s cryptodev-2s Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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', () => {
Expand All @@ -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({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
source.delegateAll({
// We purposely make no assertions here;
// this test file will fail if there are type errors.
source.delegateAll({

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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', () => {
Expand All @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -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: [],
});
});
});
});
Loading
Loading