-
Notifications
You must be signed in to change notification settings - Fork 62
/
jest.ts
35 lines (31 loc) · 1.03 KB
/
jest.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { StylableConfig } from '@stylable/core';
import { Options, stylableModuleFactory } from '@stylable/module-utils';
import fs from 'fs';
const stylableRuntimePath = require.resolve('@stylable/runtime');
export function processFactory(
stylableConfig?: Partial<StylableConfig>,
factoryOptions?: Partial<Options>
) {
return stylableModuleFactory(
{
fileSystem: fs,
requireModule: require,
projectRoot: '',
...stylableConfig
},
// ensure the generated module points to our own @stylable/runtime copy
// this allows @stylable/jest to be used as part of a globally installed CLI
{ runtimePath: stylableRuntimePath, ...factoryOptions }
);
}
export const process = processFactory();
export function getCacheKey(
fileData: string,
filename: string,
configString: string,
{ instrument }: { instrument: boolean }
) {
return (
fileData + configString + (instrument ? 'instrument' : '') + filename + stylableRuntimePath
);
}