mirror of
https://github.com/apache/superset.git
synced 2026-05-29 20:29:34 +00:00
63 lines
2.4 KiB
TypeScript
63 lines
2.4 KiB
TypeScript
/**
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
* or more contributor license agreements. See the NOTICE file
|
|
* distributed with this work for additional information
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
* to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance
|
|
* with the License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
* KIND, either express or implied. See the License for the
|
|
* specific language governing permissions and limitations
|
|
* under the License.
|
|
*/
|
|
import './shim';
|
|
// eslint-disable-next-line no-restricted-syntax -- whole React import is required for mocking React module in tests.
|
|
import React from 'react';
|
|
// eslint-disable-next-line no-restricted-imports
|
|
import { configure as configureTestingLibrary } from '@testing-library/react';
|
|
import { matchers } from '@emotion/jest';
|
|
import failOnConsole from 'jest-fail-on-console';
|
|
|
|
// Fail tests only on React 19 deprecation/removal warnings surfaced by React 18.3
|
|
// (other console.error/warn output is left alone during the migration).
|
|
const REACT_19_DEPRECATION_PATTERNS = [
|
|
/Support for defaultProps will be removed/,
|
|
/ReactDOM\.render is no longer supported/,
|
|
/ReactDOM\.hydrate is no longer supported/,
|
|
/unmountComponentAtNode is deprecated/,
|
|
/findDOMNode is deprecated/,
|
|
/String refs are deprecated/,
|
|
/Legacy context API has been detected/,
|
|
/`ReactDOMTestUtils\.act` is deprecated/,
|
|
/will be removed in (a future major release|React 19)/,
|
|
];
|
|
|
|
failOnConsole({
|
|
shouldFailOnError: true,
|
|
shouldFailOnWarn: true,
|
|
silenceMessage: message =>
|
|
!REACT_19_DEPRECATION_PATTERNS.some(pattern => pattern.test(message)),
|
|
});
|
|
|
|
configureTestingLibrary({
|
|
testIdAttribute: 'data-test',
|
|
});
|
|
|
|
document.body.innerHTML = '<div id="app" data-bootstrap=""></div>';
|
|
expect.extend(matchers);
|
|
|
|
// Allow JSX tests to have React import readily available
|
|
global.React = React;
|
|
|
|
// Mock ace-builds globally for tests
|
|
jest.mock('ace-builds/src-min-noconflict/mode-handlebars', () => ({}));
|
|
jest.mock('ace-builds/src-min-noconflict/mode-css', () => ({}));
|
|
jest.mock('ace-builds/src-noconflict/theme-github', () => ({}));
|
|
jest.mock('ace-builds/src-noconflict/theme-monokai', () => ({}));
|