本文整理汇总了TypeScript中jest-runtime.requireModule函数的典型用法代码示例。如果您正苦于以下问题:TypeScript requireModule函数的具体用法?TypeScript requireModule怎么用?TypeScript requireModule使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了requireModule函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: jasmine2
//.........这里部分代码省略.........
fit.result.__callsite = stack;
return fit;
}) as Global.Global['fit'];
}
jasmineAsyncInstall(globalConfig, environment.global);
installEach(environment);
environment.global.test = environment.global.it;
environment.global.it.only = environment.global.fit;
environment.global.it.todo = env.todo;
environment.global.it.skip = environment.global.xit;
environment.global.xtest = environment.global.xit;
environment.global.describe.skip = environment.global.xdescribe;
environment.global.describe.only = environment.global.fdescribe;
if (config.timers === 'fake') {
environment.fakeTimers!.useFakeTimers();
}
env.beforeEach(() => {
if (config.resetModules) {
runtime.resetModules();
}
if (config.clearMocks) {
runtime.clearAllMocks();
}
if (config.resetMocks) {
runtime.resetAllMocks();
if (config.timers === 'fake') {
environment.fakeTimers!.useFakeTimers();
}
}
if (config.restoreMocks) {
runtime.restoreAllMocks();
}
});
env.addReporter(reporter);
runtime
.requireInternalModule(path.resolve(__dirname, './jestExpect.js'))
.default({
expand: globalConfig.expand,
});
if (globalConfig.errorOnDeprecated) {
installErrorOnPrivate(environment.global);
} else {
// $FlowFixMe Flow seems to be confused about accessors and tries to enforce having a `value` property.
Object.defineProperty(jasmine, 'DEFAULT_TIMEOUT_INTERVAL', {
configurable: true,
enumerable: true,
get() {
return this._DEFAULT_TIMEOUT_INTERVAL;
},
set(value) {
this._DEFAULT_TIMEOUT_INTERVAL = value;
},
});
}
const snapshotState: SnapshotStateType = runtime
.requireInternalModule(path.resolve(__dirname, './setup_jest_globals.js'))
.default({
config,
globalConfig,
localRequire: runtime.requireModule.bind(runtime),
testPath,
});
config.setupFilesAfterEnv.forEach((path: Config.Path) =>
runtime.requireModule(path),
);
if (globalConfig.enabledTestsMap) {
env.specFilter = (spec: Spec) => {
const suiteMap =
globalConfig.enabledTestsMap &&
globalConfig.enabledTestsMap[spec.result.testPath];
return suiteMap && suiteMap[spec.result.fullName];
};
} else if (globalConfig.testNamePattern) {
const testNameRegex = new RegExp(globalConfig.testNamePattern, 'i');
env.specFilter = (spec: Spec) => testNameRegex.test(spec.getFullName());
}
runtime.requireModule(testPath);
await env.execute();
const results = await reporter.getResults();
return addSnapshotData(results, snapshotState);
}
开发者ID:Volune,项目名称:jest,代码行数:101,代码来源:index.ts
示例2:
config.setupFilesAfterEnv.forEach(path => runtime.requireModule(path));
开发者ID:facebook,项目名称:jest,代码行数:1,代码来源:jestAdapter.ts
示例3:
config.setupFilesAfterEnv.forEach((path: Config.Path) =>
runtime.requireModule(path),
开发者ID:Volune,项目名称:jest,代码行数:2,代码来源:index.ts
示例4: async
const jestAdapter = async (
globalConfig: Config.GlobalConfig,
config: Config.ProjectConfig,
environment: JestEnvironment,
runtime: Runtime,
testPath: string,
): Promise<TestResult> => {
const {
initialize,
runAndTransformResultsToJestFormat,
} = runtime.requireInternalModule(FRAMEWORK_INITIALIZER);
runtime
.requireInternalModule(path.resolve(__dirname, './jestExpect.js'))
.default({
expand: globalConfig.expand,
});
const getPrettier = () =>
config.prettierPath ? require(config.prettierPath) : null;
const getBabelTraverse = () => require('@babel/traverse').default;
const {globals, snapshotState} = initialize({
config,
environment,
getBabelTraverse,
getPrettier,
globalConfig,
localRequire: runtime.requireModule.bind(runtime),
parentProcess: process,
testPath,
});
if (config.timers === 'fake') {
// during setup, this cannot be null (and it's fine to explode if it is)
environment.fakeTimers!.useFakeTimers();
}
globals.beforeEach(() => {
if (config.resetModules) {
runtime.resetModules();
}
if (config.clearMocks) {
runtime.clearAllMocks();
}
if (config.resetMocks) {
runtime.resetAllMocks();
if (config.timers === 'fake') {
// during setup, this cannot be null (and it's fine to explode if it is)
environment.fakeTimers!.useFakeTimers();
}
}
if (config.restoreMocks) {
runtime.restoreAllMocks();
}
});
config.setupFilesAfterEnv.forEach(path => runtime.requireModule(path));
runtime.requireModule(testPath);
const results = await runAndTransformResultsToJestFormat({
config,
globalConfig,
testPath,
});
return _addSnapshotData(results, snapshotState);
};
开发者ID:facebook,项目名称:jest,代码行数:71,代码来源:jestAdapter.ts
注:本文中的jest-runtime.requireModule函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论