Javascript setupTest.ts与setTest.js文件

Javascript setupTest.ts与setTest.js文件,javascript,reactjs,typescript,jestjs,enzyme,Javascript,Reactjs,Typescript,Jestjs,Enzyme,我正在将React项目从js移到ts。我正在努力设置我的setupTest文件 到目前为止,我的文件设置如下 import React from 'react'; import {configure, shallow, render, mount} from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; import {expect, it} from '@jest/globals'; import {act} from '@t

我正在将React项目从js移到ts。我正在努力设置我的
setupTest
文件

到目前为止,我的文件设置如下

import React from 'react';
import {configure, shallow, render, mount} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import {expect, it} from '@jest/globals';
import {act} from '@testing-library/react';
import {createSerializer} from 'enzyme-to-json';
import sinon from 'sinon';

//utility test functions
import {
    expectSnapshot,
    // findToHaveLength,
    // expectTextToEqual,
    // onSelectDropdown,
    // simulateBtnClick,
    // classListContainsFalsy,
    // classListContainsTruthy,
    // createDivBody
} from "./src/renderer/Utils/test_utils";


// required so that enzyme and jest don't complain...
window.require = require;

// Set the default serializer for Jest to be the from enzyme-to-json
// This produces an easier to read serialized format
expect.addSnapshotSerializer(createSerializer({mode: 'deep'}));

// React 16 Enzyme adapter
configure({adapter: new Adapter()});

// Make Enzyme Functions available in al test files without importing

global.shallow = shallow;
global.render = render;
global.mount = mount;
global.sinon = sinon;
global.act = act;
global.expect = expect;
global.it = it;


//utility test functions
global.expectSnapshot = expectSnapshot;
// global.findToHaveLength = findToHaveLength;
// global.expectTextToEqual = expectTextToEqual;
// global.simulateBtnClick = simulateBtnClick;
// global.onSelectDropdown = onSelectDropdown;
// global.classListContainsTruthy = classListContainsTruthy;
// global.classListContainsFalsy = classListContainsFalsy;
// global.createDivBody = createDivBody;

例如,我在计算
global.shallow=shallow
的等效值时遇到了问题。这适用于我的
js
版本,但不适用于typeScript。任何建议都太好了