1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00

Chore: Disable Jest console wrapper in tests

This commit is contained in:
Laurent Cozic 2023-12-15 18:34:21 +00:00
parent d2fe33183b
commit e47ac1de6a
7 changed files with 23 additions and 0 deletions

16
jest.base-setup.js Normal file
View File

@ -0,0 +1,16 @@
/* eslint-disable jest/require-top-level-describe */
module.exports = () => {
// Disable the additional information that Jest adds to each console
// statement. It's rarely needed and if it is it can be commented out here.
const jestConsole = console;
beforeEach(() => {
global.console = require('console');
});
afterEach(() => {
global.console = jestConsole;
});
};

View File

@ -3,6 +3,7 @@ const { shimInit } = require('@joplin/lib/shim-init-node.js');
const shim = require('@joplin/lib/shim').default;
const sharp = require('sharp');
const nodeSqlite = require('sqlite3');
require('../../jest.base-setup.js')();
let keytar;
try {

View File

@ -3,6 +3,7 @@
const { shimInit } = require('@joplin/lib/shim-init-node');
const sqlite3 = require('sqlite3');
const SyncTargetNone = require('@joplin/lib/SyncTargetNone').default;
require('../../jest.base-setup.js')();
// Mock the S3 sync target -- the @aws-s3 libraries depend on an old version
// of uuid that doesn't work with jest without additional configuration.

View File

@ -7,6 +7,7 @@ const path = require('path');
const { tmpdir } = require('os');
const uuid = require('@joplin/lib/uuid').default;
const sqlite3 = require('sqlite3');
require('../../jest.base-setup.js')();
import { setImmediate } from 'timers';

View File

@ -1,3 +1,4 @@
require('../../jest.base-setup.js')();
// Prevents the CodeMirror error "getClientRects is undefined".
// See https://github.com/jsdom/jsdom/issues/3002#issue-652790925

View File

@ -4,6 +4,8 @@ const sharp = require('sharp');
const nodeSqlite = require('sqlite3');
const pdfJs = require('pdfjs-dist');
require('../../jest.base-setup.js')();
shimInit({ sharp, nodeSqlite, pdfJs });
global.afterEach(async () => {

View File

@ -1,5 +1,6 @@
const { shimInit } = require('@joplin/lib/shim-init-node.js');
const nodeSqlite = require('sqlite3');
require('../../jest.base-setup.js')();
shimInit({ nodeSqlite });