Many, perhaps all, test script files share the same scaffold.
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import checkWorkspaceCache from '../../../mod/workspace/cache.js';
//Assigning console.error to a property to restore original function with.
const originalConsole = console.error;
//erros from test so we can assert on them and not get polute the console.
const mockErrors = [];
beforeAll(() => {
//Changing the console.error function to push to our local collection of messages.
console.error = (message) => {
mockErrors.push(message);
};
});
afterAll(() => {
console.error = originalConsole;
});
It might be beneficially to define this once in a test scaffold script to be imported by each of the test scripts.
Many, perhaps all, test script files share the same scaffold.
It might be beneficially to define this once in a test scaffold script to be imported by each of the test scripts.