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
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"editor.defaultFormatter": "oxc.oxc-vscode",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"typescript.enablePromptUseWorkspaceTsdk": true,
"typescript.tsdk": "node_modules/typescript/lib",
"js/ts.tsdk.promptToUseWorkspaceVersion": true,
"js/ts.tsdk.path": "node_modules/typescript/lib",
"files.readonlyInclude": {
"**/routeTree.gen.ts": true
},
Expand Down
14 changes: 13 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,19 @@ copy(
'vitest/no-mocks-import': 1,
'vitest/no-restricted-matchers': 0,
'vitest/no-restricted-vi-methods': 0,
'vitest/no-standalone-expect': 1,
'vitest/no-standalone-expect': [
1,
{
additionalTestBlockFunctions: [
'beforeAll',
'beforeEach',
'afterAll',
'afterEach',
'aroundAll',
'aroundEach'
]
}
],
'vitest/no-test-prefixes': 1,
'vitest/no-test-return-statement': 1,
'vitest/no-unneeded-async-expect-function': 1,
Expand Down
51 changes: 25 additions & 26 deletions test/failOnConsole.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
let consoleErrorOrConsoleWarnWereCalled = false;

beforeAll(() => {
// replace instead of mutating `console` to avoid infinite loops
globalThis.console = {
...console,
error(...params) {
if (
params[0] instanceof Error &&
params[0].message === 'ResizeObserver loop completed with undelivered notifications.'
) {
return;
}

consoleErrorOrConsoleWarnWereCalled = true;
console.log(...params);
},
warn(...params) {
consoleErrorOrConsoleWarnWereCalled = true;
console.log(...params);
console.error = (...params) => {
if (
params[0] instanceof Error &&
params[0].message === 'ResizeObserver loop completed with undelivered notifications.'
) {
return;
}

consoleErrorOrConsoleWarnWereCalled = true;
console.log(...params);
};

console.warn = (...params) => {
consoleErrorOrConsoleWarnWereCalled = true;
console.log(...params);
};
});

afterEach(() => {
// Wait for both the test and `afterEach` hooks to complete to ensure all logs are caught
afterEach(({ task, signal }) => {
// Wait for the test and all `afterEach` hooks to complete to ensure all logs are caught
onTestFinished(() => {
// eslint-disable-next-line vitest/no-standalone-expect
expect
.soft(
consoleErrorOrConsoleWarnWereCalled,
'console.error() and/or console.warn() were called during the test'
)
.toBe(false);
// avoid failing test runs twice
if (task.result!.state !== 'fail' || signal.aborted) {
expect
.soft(
consoleErrorOrConsoleWarnWereCalled,
'errors/warnings were logged to the console during the test'
)
.toBe(false);
}

consoleErrorOrConsoleWarnWereCalled = false;
});
Expand Down
1 change: 0 additions & 1 deletion test/setupBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ beforeEach(async () => {
afterEach(() => {
vi.useRealTimers();

// eslint-disable-next-line vitest/no-standalone-expect
expect
.soft(
document.hasFocus(),
Expand Down
Loading