本文整理汇总了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);
}
示例2:
config.setupFilesAfterEnv.forEach(path => runtime.requireModule(path));
示例3:
config.setupFilesAfterEnv.forEach((path: Config.Path) =>
runtime.requireModule(path),
示例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);
};