1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Chore: Mobile: Tests: Fix CodeMirror-related error messages (#8569)

This commit is contained in:
Henry Heino 2023-07-29 08:33:39 -07:00 committed by GitHub
parent 46ccd94514
commit f76ae86204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 23 deletions

View File

@ -1,7 +1,3 @@
/**
* @jest-environment jsdom
*/
import { EditorSelection } from '@codemirror/state';
import { ListType } from '../types';
import createEditor from './testUtil/createEditor';

View File

@ -1,7 +1,3 @@
/**
* @jest-environment jsdom
*/
import { EditorSelection } from '@codemirror/state';
import {
toggleBolded, toggleCode, toggleHeaderLevel, toggleItalicized, toggleMath, updateLink,

View File

@ -1,7 +1,3 @@
/**
* @jest-environment jsdom
*/
import { EditorSelection, EditorState } from '@codemirror/state';
import {
increaseIndent, toggleList,

View File

@ -1,6 +1,3 @@
/**
* @jest-environment jsdom
*/
import { syntaxTree } from '@codemirror/language';
import { SyntaxNode } from '@lezer/common';
import { EditorSelection, EditorState } from '@codemirror/state';

View File

@ -1,12 +1,4 @@
/**
* @jest-environment jsdom
*/
import * as React from 'react';
import { setImmediate } from 'timers';
// Required by some libraries (setImmediate is not supported in most browsers,
// so is removed by jsdom).
window.setImmediate = setImmediate;
import { _ } from '@joplin/lib/locale';
import { act, fireEvent, render, waitFor } from '@testing-library/react-native';

View File

@ -12,6 +12,7 @@ module.exports = {
'\\.(ts|tsx)$': 'ts-jest',
},
testEnvironment: 'jsdom',
testMatch: ['**/*.test.(ts|tsx)'],
testPathIgnorePatterns: ['<rootDir>/node_modules/'],

View File

@ -8,6 +8,29 @@ const { tmpdir } = require('os');
const uuid = require('@joplin/lib/uuid').default;
const sqlite3 = require('sqlite3');
import { setImmediate } from 'timers';
// Required by some libraries (setImmediate is not supported in most browsers,
// so is removed by jsdom).
window.setImmediate = setImmediate;
// Prevents the CodeMirror error "getClientRects is undefined".
// See https://github.com/jsdom/jsdom/issues/3002#issue-652790925
document.createRange = () => {
const range = new Range();
range.getBoundingClientRect = jest.fn();
range.getClientRects = () => {
return {
length: 0,
item: () => null,
[Symbol.iterator]: jest.fn(),
};
};
return range;
};
shimInit({ nodeSqlite: sqlite3 });