如何在开玩笑测试中包含来自Web的文件

ric*_*een 6 reactjs jestjs

我有一个我正在测试的脚本,它依赖于html页面标题中包含的其他脚本.使用jest测试模块时,永远不会获取这些文件,我想知道如何将它们包含在测试中,以便我的模块可以访问运行所需的函数.

示例html:

<script src="http://example.com/my.js"></script>
Run Code Online (Sandbox Code Playgroud)

开玩笑测试:

jest.unmock('../addeditCreditModal.jsx');
jest.unmock('../../../utils/dataPreprocessor.js');
var $ = require("../../../../../../jquery.min.js");
describe('ADDEDIT', () => {
    const AE = require('../addeditCreditModal.jsx').default;
    const React = require('react');
    const ReactDOM = require('react-dom');
    const TestUtils = require('react-addons-test-utils');

    it('add edit', () => {
        window.$ = require("../../../../../../jquery.min.js");
        //here I need to include a file, bcuase functions will be called when mounting the module, like jquery, which is on my machine, but the web file is not.
        //importScripts("http://example.com/my.js");
        const landing = TestUtils.renderIntoDocument(
            <AE 
                closeModal={jest.genMockFn()} 
            />
        );
    });
});
Run Code Online (Sandbox Code Playgroud)

我想要包含的java脚本不是模块,只是将通用java脚本附加到窗口的函数.