Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何在jest测试中包含来自web的文件_Reactjs_Jestjs - Fatal编程技术网

Reactjs 如何在jest测试中包含来自web的文件

Reactjs 如何在jest测试中包含来自web的文件,reactjs,jestjs,Reactjs,Jestjs,我正在测试一个脚本,它依赖于html页面标题中包含的其他脚本。当使用jest测试模块时,这些文件永远不会被获取,我想知道如何将它们包括在测试中,以便我的模块能够访问它们需要运行的函数 html示例: <script src="http://example.com/my.js"></script> 玩笑测试: jest.unmock('../addeditCreditModal.jsx'); jest.unmock('../../../utils/dataPrepro

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

html示例:

<script src="http://example.com/my.js"></script>

玩笑测试:

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()} 
            />
        );
    });
});
jest.unmack('../addeditCreditModal.jsx');
unmack('../../../utils/dataPreprocessor.js');
var$=require(“../../../../../jquery.min.js”);
描述('ADDEDIT',()=>{
const AE=require('../addeditCreditModal.jsx')。默认值;
const React=require('React');
const ReactDOM=require('react-dom');
const TestUtils=require('react-addons-test-utils');
它('添加编辑',()=>{
window.$=require(“../../../../../jquery.min.js”);
//这里我需要包含一个文件,在装载模块时将调用bcuase函数,比如jquery,它在我的机器上,但是web文件不是。
//进口文件(“http://example.com/my.js");
const landing=TestUtils.renderIntoDocument(
);
});
});
我想包含的java脚本不是一个模块,只是将函数附加到窗口的通用java脚本