@taqueria/plugin-jest 0.0.0-pr-1012-58aefa83 → 0.0.0-pr-852-a3ccfd4e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common.ts +91 -0
- package/contractTestTemplate.ts +109 -0
- package/index.cjs +201 -0
- package/index.cjs.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +183 -100
- package/index.js.map +1 -1
- package/index.ts +28 -2
- package/package.json +24 -13
- package/proxy.ts +8 -93
- package/tsconfig.json +7 -4
package/common.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { noop, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';
|
|
2
|
+
import { LoadedConfig, RequestArgs, SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';
|
|
3
|
+
import { mkdir, stat, writeFile } from 'fs/promises';
|
|
4
|
+
import { defaults } from 'jest-config';
|
|
5
|
+
import { join, relative } from 'path';
|
|
6
|
+
|
|
7
|
+
export type DefaultConfig = typeof defaults;
|
|
8
|
+
|
|
9
|
+
export interface CustomConfig extends LoadedConfig.t {
|
|
10
|
+
readonly jestTestsRootDir?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface CustomRequestArgs extends RequestArgs.t {
|
|
14
|
+
config: CustomConfig;
|
|
15
|
+
partition?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const toRequestArgs = (args: RequestArgs.t) => (args as CustomRequestArgs);
|
|
19
|
+
|
|
20
|
+
export const getDefaultConfig = (defaultConfig: DefaultConfig) => `
|
|
21
|
+
module.exports = ${JSON.stringify(defaults, null, 4)}
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
export const ensureRootConfigExists = (projectDir: SanitizedAbsPath.t) => {
|
|
25
|
+
const jestRootConfig = getRootConfigAbspath(projectDir);
|
|
26
|
+
return stat(jestRootConfig)
|
|
27
|
+
.catch(_ => writeFile(jestRootConfig, getDefaultConfig(defaults)))
|
|
28
|
+
.then(_ => jestRootConfig);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const getRootConfigAbspath = (projectDir: SanitizedAbsPath.t) =>
|
|
32
|
+
SanitizedAbsPath.create(
|
|
33
|
+
join(projectDir, '.taq', 'jest.config.js'),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export const getTestsRootDir = (config: CustomConfig) => {
|
|
37
|
+
return config.jestTestsRootDir || 'tests';
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const toPartitionCfg = (partitionRelpath: SanitizedPath.t, rootConfigRelPath: SanitizedPath.t) => `
|
|
41
|
+
const parentConfig = require('${rootConfigRelPath}')
|
|
42
|
+
|
|
43
|
+
module.exports = {
|
|
44
|
+
...parentConfig,
|
|
45
|
+
roots: [
|
|
46
|
+
"${partitionRelpath}"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
export const getPartitionAbspath = (partitionDir: string) => SanitizedAbsPath.create(partitionDir);
|
|
52
|
+
|
|
53
|
+
export const getPartitionConfigAbspath = (partitionDir: string) =>
|
|
54
|
+
SanitizedAbsPath.create(join(partitionDir, 'jest.config.js'));
|
|
55
|
+
|
|
56
|
+
export const createPartition = async (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) =>
|
|
57
|
+
ensureRootConfigExists(projectDir)
|
|
58
|
+
.then(_ => stat(partitionDir))
|
|
59
|
+
.then(stats =>
|
|
60
|
+
stats.isFile()
|
|
61
|
+
? sendAsyncErr(`${partitionDir} is an invalid partition directory`)
|
|
62
|
+
: stats
|
|
63
|
+
)
|
|
64
|
+
.catch(_ => mkdir(partitionDir, { recursive: true }))
|
|
65
|
+
.then(_ => getPartitionConfigAbspath(partitionDir))
|
|
66
|
+
.then(partitionCfgAbsPath =>
|
|
67
|
+
stat(partitionCfgAbsPath)
|
|
68
|
+
.catch(_ =>
|
|
69
|
+
writeFile(
|
|
70
|
+
partitionCfgAbsPath,
|
|
71
|
+
toPartitionCfg(
|
|
72
|
+
SanitizedPath.create(relative(partitionDir, partitionDir)),
|
|
73
|
+
SanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),
|
|
74
|
+
),
|
|
75
|
+
)
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
.then(_ => getPartitionConfigAbspath(partitionDir));
|
|
79
|
+
|
|
80
|
+
export const ensurePartitionExists = (args: CustomRequestArgs) =>
|
|
81
|
+
args.partition
|
|
82
|
+
? createPartition(
|
|
83
|
+
SanitizedAbsPath.create(join(args.projectDir, args.partition)),
|
|
84
|
+
args.projectDir,
|
|
85
|
+
)
|
|
86
|
+
: createPartition(
|
|
87
|
+
SanitizedAbsPath.create(
|
|
88
|
+
join(args.projectDir, getTestsRootDir(args.config)),
|
|
89
|
+
),
|
|
90
|
+
args.projectDir,
|
|
91
|
+
);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// import { normalizeContractName } from '@taqueria/plugin-contract-types/src/generator/contract-name';
|
|
2
|
+
import { sendAsyncRes } from '@taqueria/node-sdk';
|
|
3
|
+
import { generateContractTypesProcessContractFiles } from '@taqueria/plugin-contract-types/src/cli-process.js';
|
|
4
|
+
import {
|
|
5
|
+
createTestingCodeGenerator,
|
|
6
|
+
normalizeContractName,
|
|
7
|
+
} from '@taqueria/plugin-contract-types/src/generator/testing-code-generator.js';
|
|
8
|
+
import { readFile, stat, writeFile } from 'fs/promises';
|
|
9
|
+
import { basename, dirname, join } from 'path';
|
|
10
|
+
import { CustomRequestArgs, ensurePartitionExists, getPartitionAbspath, getTestsRootDir } from './common';
|
|
11
|
+
|
|
12
|
+
type Generator = ReturnType<typeof createTestingCodeGenerator>;
|
|
13
|
+
|
|
14
|
+
interface Opts extends CustomRequestArgs {
|
|
15
|
+
readonly michelsonArtifact: string;
|
|
16
|
+
readonly partition?: string;
|
|
17
|
+
readonly name?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const getMichelsonAbspath = (parsedArgs: Opts) => join(parsedArgs.config.artifactsDir, parsedArgs.michelsonArtifact);
|
|
21
|
+
|
|
22
|
+
const ensureMichelsonExists = (parsedArgs: Opts) => {
|
|
23
|
+
const abspath = getMichelsonAbspath(parsedArgs);
|
|
24
|
+
return stat(abspath)
|
|
25
|
+
.then(() => parsedArgs)
|
|
26
|
+
.catch(() => Promise.reject(`${abspath} does not exist. Perhaps you need to run "taq compile"?`));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const getPartition = (parsedArgs: Opts) => {
|
|
30
|
+
const partition = parsedArgs.partition ?? getTestsRootDir(parsedArgs.config);
|
|
31
|
+
return getPartitionAbspath(partition);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const getTypesOutputAbspath = (parsedArgs: Opts) => join(getPartition(parsedArgs), 'types');
|
|
35
|
+
|
|
36
|
+
const generateContractTypes = (parsedArgs: Opts) =>
|
|
37
|
+
generateContractTypesProcessContractFiles({
|
|
38
|
+
inputTzContractDirectory: parsedArgs.config.artifactsDir,
|
|
39
|
+
inputFiles: [getMichelsonAbspath(parsedArgs)],
|
|
40
|
+
outputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),
|
|
41
|
+
format: 'tz',
|
|
42
|
+
typeAliasMode: 'file',
|
|
43
|
+
}).then(_ => parsedArgs);
|
|
44
|
+
|
|
45
|
+
const getContractName = (parsedArgs: Opts) => parsedArgs.name ?? basename(parsedArgs.michelsonArtifact, '.tz');
|
|
46
|
+
|
|
47
|
+
const generateTestSuite = (parsedArgs: Opts) => {
|
|
48
|
+
const michelsonAbspath = getMichelsonAbspath(parsedArgs);
|
|
49
|
+
const contractName = getContractName(parsedArgs);
|
|
50
|
+
const partition = getPartition(parsedArgs);
|
|
51
|
+
const jestSuiteAbspath = join(partition, `${contractName}.ts`);
|
|
52
|
+
|
|
53
|
+
return readFile(michelsonAbspath, { encoding: 'utf-8' })
|
|
54
|
+
.then(contractSource => ({ contractSource, contractFormat: 'tz' as const }))
|
|
55
|
+
.then(createTestingCodeGenerator)
|
|
56
|
+
.then(toJest(contractName))
|
|
57
|
+
.then(contents => writeFile(jestSuiteAbspath, contents, { encoding: 'utf-8' }))
|
|
58
|
+
.then(() => jestSuiteAbspath);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const toJest = (contractName: string) =>
|
|
62
|
+
(generator: Generator) => {
|
|
63
|
+
const methodCalls = generator.methods.map(m => ({
|
|
64
|
+
name: m.name,
|
|
65
|
+
methodCall: generator.generateMethodCall({
|
|
66
|
+
methodName: m.name,
|
|
67
|
+
formatting: {
|
|
68
|
+
indent: 2,
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
storageAccess: generator.generateStorageAccess({ storagePath: '' }),
|
|
72
|
+
}));
|
|
73
|
+
return `
|
|
74
|
+
import { TezosToolkit } from '@taquito/taquito';
|
|
75
|
+
import { char2Bytes } from '@taquito/utils';
|
|
76
|
+
import { tas } from './types/type-aliases';
|
|
77
|
+
import { ${normalizeContractName(contractName)}ContractType as ContractType } from './types/${contractName}.types';
|
|
78
|
+
import { ${normalizeContractName(contractName)}Code as ContractCode } from './types/${contractName}.code';
|
|
79
|
+
|
|
80
|
+
describe('${contractName}', () => {
|
|
81
|
+
const Tezos = new TezosToolkit('RPC_URL');
|
|
82
|
+
let contract: ContractType = undefined as unknown as ContractType;
|
|
83
|
+
beforeAll(async () => {
|
|
84
|
+
${generator.generateOrigination({ formatting: { indent: 3 } }).code}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
${
|
|
88
|
+
methodCalls.map(x => `
|
|
89
|
+
it('should call ${x.name}', async () => {
|
|
90
|
+
${x.storageAccess.getStorageValueFunctionCode}
|
|
91
|
+
const storageValueBefore = await ${x.storageAccess.getStorageValueFunctionName}();
|
|
92
|
+
${x.methodCall.code}
|
|
93
|
+
const storageValueAfter = await ${x.storageAccess.getStorageValueFunctionName}();
|
|
94
|
+
|
|
95
|
+
expect(storageValueAfter).toBe('');
|
|
96
|
+
});
|
|
97
|
+
`).join('')
|
|
98
|
+
});
|
|
99
|
+
`;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default (parsedArgs: Opts) => {
|
|
103
|
+
return ensureMichelsonExists(parsedArgs)
|
|
104
|
+
.then(ensurePartitionExists)
|
|
105
|
+
.then(() => parsedArgs)
|
|
106
|
+
.then(generateContractTypes)
|
|
107
|
+
.then(generateTestSuite)
|
|
108
|
+
.then(outFile => sendAsyncRes(`Test suite generated: ${outFile}`));
|
|
109
|
+
};
|
package/index.cjs
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// index.ts
|
|
4
|
+
var import_node_sdk4 = require("@taqueria/node-sdk");
|
|
5
|
+
|
|
6
|
+
// common.ts
|
|
7
|
+
var import_node_sdk = require("@taqueria/node-sdk");
|
|
8
|
+
var import_types = require("@taqueria/node-sdk/types");
|
|
9
|
+
var import_promises = require("fs/promises");
|
|
10
|
+
var import_jest_config = require("jest-config");
|
|
11
|
+
var import_path = require("path");
|
|
12
|
+
var toRequestArgs = (args) => args;
|
|
13
|
+
var getDefaultConfig = (defaultConfig) => `
|
|
14
|
+
module.exports = ${JSON.stringify(import_jest_config.defaults, null, 4)}
|
|
15
|
+
`;
|
|
16
|
+
var ensureRootConfigExists = (projectDir) => {
|
|
17
|
+
const jestRootConfig = getRootConfigAbspath(projectDir);
|
|
18
|
+
return (0, import_promises.stat)(jestRootConfig).catch((_) => (0, import_promises.writeFile)(jestRootConfig, getDefaultConfig(import_jest_config.defaults))).then((_) => jestRootConfig);
|
|
19
|
+
};
|
|
20
|
+
var getRootConfigAbspath = (projectDir) => import_types.SanitizedAbsPath.create((0, import_path.join)(projectDir, ".taq", "jest.config.js"));
|
|
21
|
+
var getTestsRootDir = (config) => {
|
|
22
|
+
return config.jestTestsRootDir || "tests";
|
|
23
|
+
};
|
|
24
|
+
var toPartitionCfg = (partitionRelpath, rootConfigRelPath) => `
|
|
25
|
+
const parentConfig = require('${rootConfigRelPath}')
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
...parentConfig,
|
|
29
|
+
roots: [
|
|
30
|
+
"${partitionRelpath}"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
var getPartitionAbspath = (partitionDir) => import_types.SanitizedAbsPath.create(partitionDir);
|
|
35
|
+
var getPartitionConfigAbspath = (partitionDir) => import_types.SanitizedAbsPath.create((0, import_path.join)(partitionDir, "jest.config.js"));
|
|
36
|
+
var createPartition = async (partitionDir, projectDir) => ensureRootConfigExists(projectDir).then((_) => (0, import_promises.stat)(partitionDir)).then((stats) => stats.isFile() ? (0, import_node_sdk.sendAsyncErr)(`${partitionDir} is an invalid partition directory`) : stats).catch((_) => (0, import_promises.mkdir)(partitionDir, { recursive: true })).then((_) => getPartitionConfigAbspath(partitionDir)).then((partitionCfgAbsPath) => (0, import_promises.stat)(partitionCfgAbsPath).catch((_) => (0, import_promises.writeFile)(partitionCfgAbsPath, toPartitionCfg(import_types.SanitizedPath.create((0, import_path.relative)(partitionDir, partitionDir)), import_types.SanitizedPath.create((0, import_path.relative)(partitionDir, getRootConfigAbspath(projectDir))))))).then((_) => getPartitionConfigAbspath(partitionDir));
|
|
37
|
+
var ensurePartitionExists = (args) => args.partition ? createPartition(import_types.SanitizedAbsPath.create((0, import_path.join)(args.projectDir, args.partition)), args.projectDir) : createPartition(import_types.SanitizedAbsPath.create((0, import_path.join)(args.projectDir, getTestsRootDir(args.config))), args.projectDir);
|
|
38
|
+
|
|
39
|
+
// contractTestTemplate.ts
|
|
40
|
+
var import_node_sdk2 = require("@taqueria/node-sdk");
|
|
41
|
+
var import_cli_process = require("@taqueria/plugin-contract-types/src/cli-process.js");
|
|
42
|
+
var import_testing_code_generator = require("@taqueria/plugin-contract-types/src/generator/testing-code-generator.js");
|
|
43
|
+
var import_promises2 = require("fs/promises");
|
|
44
|
+
var import_path2 = require("path");
|
|
45
|
+
var getMichelsonAbspath = (parsedArgs) => (0, import_path2.join)(parsedArgs.config.artifactsDir, parsedArgs.michelsonArtifact);
|
|
46
|
+
var ensureMichelsonExists = (parsedArgs) => {
|
|
47
|
+
const abspath = getMichelsonAbspath(parsedArgs);
|
|
48
|
+
return (0, import_promises2.stat)(abspath).then(() => parsedArgs).catch(() => Promise.reject(`${abspath} does not exist. Perhaps you need to run "taq compile"?`));
|
|
49
|
+
};
|
|
50
|
+
var getPartition = (parsedArgs) => {
|
|
51
|
+
const partition = parsedArgs.partition ?? getTestsRootDir(parsedArgs.config);
|
|
52
|
+
return getPartitionAbspath(partition);
|
|
53
|
+
};
|
|
54
|
+
var getTypesOutputAbspath = (parsedArgs) => (0, import_path2.join)(getPartition(parsedArgs), "types");
|
|
55
|
+
var generateContractTypes = (parsedArgs) => (0, import_cli_process.generateContractTypesProcessContractFiles)({
|
|
56
|
+
inputTzContractDirectory: parsedArgs.config.artifactsDir,
|
|
57
|
+
inputFiles: [getMichelsonAbspath(parsedArgs)],
|
|
58
|
+
outputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),
|
|
59
|
+
format: "tz",
|
|
60
|
+
typeAliasMode: "file"
|
|
61
|
+
}).then((_) => parsedArgs);
|
|
62
|
+
var getContractName = (parsedArgs) => parsedArgs.name ?? (0, import_path2.basename)(parsedArgs.michelsonArtifact, ".tz");
|
|
63
|
+
var generateTestSuite = (parsedArgs) => {
|
|
64
|
+
const michelsonAbspath = getMichelsonAbspath(parsedArgs);
|
|
65
|
+
const contractName = getContractName(parsedArgs);
|
|
66
|
+
const partition = getPartition(parsedArgs);
|
|
67
|
+
const jestSuiteAbspath = (0, import_path2.join)(partition, `${contractName}.ts`);
|
|
68
|
+
return (0, import_promises2.readFile)(michelsonAbspath, { encoding: "utf-8" }).then((contractSource) => ({ contractSource, contractFormat: "tz" })).then(import_testing_code_generator.createTestingCodeGenerator).then(toJest(contractName)).then((contents) => (0, import_promises2.writeFile)(jestSuiteAbspath, contents, { encoding: "utf-8" })).then(() => jestSuiteAbspath);
|
|
69
|
+
};
|
|
70
|
+
var toJest = (contractName) => (generator) => {
|
|
71
|
+
const methodCalls = generator.methods.map((m) => ({
|
|
72
|
+
name: m.name,
|
|
73
|
+
methodCall: generator.generateMethodCall({
|
|
74
|
+
methodName: m.name,
|
|
75
|
+
formatting: {
|
|
76
|
+
indent: 2
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
storageAccess: generator.generateStorageAccess({ storagePath: "" })
|
|
80
|
+
}));
|
|
81
|
+
return `
|
|
82
|
+
import { TezosToolkit } from '@taquito/taquito';
|
|
83
|
+
import { char2Bytes } from '@taquito/utils';
|
|
84
|
+
import { tas } from './types/type-aliases';
|
|
85
|
+
import { ${(0, import_testing_code_generator.normalizeContractName)(contractName)}ContractType as ContractType } from './types/${contractName}.types';
|
|
86
|
+
import { ${(0, import_testing_code_generator.normalizeContractName)(contractName)}Code as ContractCode } from './types/${contractName}.code';
|
|
87
|
+
|
|
88
|
+
describe('${contractName}', () => {
|
|
89
|
+
const Tezos = new TezosToolkit('RPC_URL');
|
|
90
|
+
let contract: ContractType = undefined as unknown as ContractType;
|
|
91
|
+
beforeAll(async () => {
|
|
92
|
+
${generator.generateOrigination({ formatting: { indent: 3 } }).code}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
${methodCalls.map((x) => `
|
|
96
|
+
it('should call ${x.name}', async () => {
|
|
97
|
+
${x.storageAccess.getStorageValueFunctionCode}
|
|
98
|
+
const storageValueBefore = await ${x.storageAccess.getStorageValueFunctionName}();
|
|
99
|
+
${x.methodCall.code}
|
|
100
|
+
const storageValueAfter = await ${x.storageAccess.getStorageValueFunctionName}();
|
|
101
|
+
|
|
102
|
+
expect(storageValueAfter).toBe('');
|
|
103
|
+
});
|
|
104
|
+
`).join("")});
|
|
105
|
+
`;
|
|
106
|
+
};
|
|
107
|
+
var contractTestTemplate_default = (parsedArgs) => {
|
|
108
|
+
return ensureMichelsonExists(parsedArgs).then(ensurePartitionExists).then(() => parsedArgs).then(generateContractTypes).then(generateTestSuite).then((outFile) => (0, import_node_sdk2.sendAsyncRes)(`Test suite generated: ${outFile}`));
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// proxy.ts
|
|
112
|
+
var import_node_sdk3 = require("@taqueria/node-sdk");
|
|
113
|
+
var import_execa = require("execa");
|
|
114
|
+
var execCmd = (cmd, args) => {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
const child = (0, import_execa.execa)(cmd, args, {
|
|
117
|
+
shell: true,
|
|
118
|
+
reject: false,
|
|
119
|
+
env: { FORCE_COLOR: "true" }
|
|
120
|
+
});
|
|
121
|
+
(_a = child.stdout) == null ? void 0 : _a.pipe(process.stdout);
|
|
122
|
+
(_b = child.stderr) == null ? void 0 : _b.pipe(process.stderr);
|
|
123
|
+
return child;
|
|
124
|
+
};
|
|
125
|
+
var proxy_default = async (args) => {
|
|
126
|
+
return ensurePartitionExists(args).then((configAbsPath) => {
|
|
127
|
+
if (!args.init) {
|
|
128
|
+
const retval = args.testPattern ? execCmd("npx", ["jest", "-c", configAbsPath, "--testPathPattern", args.testPattern]) : execCmd("npx", ["jest", "-c", configAbsPath]);
|
|
129
|
+
return retval.then((child) => {
|
|
130
|
+
if (child.exitCode === 0)
|
|
131
|
+
return;
|
|
132
|
+
else
|
|
133
|
+
process.exit(child.exitCode);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return (0, import_node_sdk3.sendAsyncRes)("Initialized successfully.");
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// index.ts
|
|
141
|
+
import_node_sdk4.Plugin.create((requestArgs) => ({
|
|
142
|
+
schema: "0.1",
|
|
143
|
+
version: "0.4.0",
|
|
144
|
+
alias: "jest",
|
|
145
|
+
tasks: [
|
|
146
|
+
import_node_sdk4.Task.create({
|
|
147
|
+
task: "test",
|
|
148
|
+
command: "test [partition]",
|
|
149
|
+
description: "Setup a directory as a partition to run Jest tests",
|
|
150
|
+
aliases: ["jest"],
|
|
151
|
+
handler: "proxy",
|
|
152
|
+
positionals: [
|
|
153
|
+
import_node_sdk4.PositionalArg.create({
|
|
154
|
+
placeholder: "partition",
|
|
155
|
+
description: "Name of the partition for these tests",
|
|
156
|
+
defaultValue: "tests",
|
|
157
|
+
type: "string"
|
|
158
|
+
})
|
|
159
|
+
],
|
|
160
|
+
options: [
|
|
161
|
+
import_node_sdk4.Option.create({
|
|
162
|
+
flag: "init",
|
|
163
|
+
shortFlag: "i",
|
|
164
|
+
description: "Initializes the partition for Jest",
|
|
165
|
+
boolean: true
|
|
166
|
+
}),
|
|
167
|
+
import_node_sdk4.Option.create({
|
|
168
|
+
flag: "testPattern",
|
|
169
|
+
shortFlag: "t",
|
|
170
|
+
description: "Run test files that match the provided pattern"
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
})
|
|
174
|
+
],
|
|
175
|
+
templates: [
|
|
176
|
+
import_node_sdk4.Template.create({
|
|
177
|
+
template: "contract-test",
|
|
178
|
+
command: "contract-test <michelsonArtifact>",
|
|
179
|
+
positionals: [
|
|
180
|
+
import_node_sdk4.PositionalArg.create({
|
|
181
|
+
placeholder: "michelsonArtifact",
|
|
182
|
+
description: "Name of the michelson contract (artifact) to generate tests for",
|
|
183
|
+
required: true,
|
|
184
|
+
type: "string"
|
|
185
|
+
})
|
|
186
|
+
],
|
|
187
|
+
options: [
|
|
188
|
+
import_node_sdk4.Option.create({
|
|
189
|
+
flag: "partition",
|
|
190
|
+
description: "Partition to place generated test suite",
|
|
191
|
+
type: "string",
|
|
192
|
+
defaultValue: toRequestArgs(requestArgs).config.jestTestsRootDir || "tests"
|
|
193
|
+
})
|
|
194
|
+
],
|
|
195
|
+
description: "Generate integration test for a contract",
|
|
196
|
+
handler: contractTestTemplate_default
|
|
197
|
+
})
|
|
198
|
+
],
|
|
199
|
+
proxy: proxy_default
|
|
200
|
+
}), process.argv);
|
|
201
|
+
//# sourceMappingURL=index.cjs.map
|
package/index.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts","common.ts","contractTestTemplate.ts","proxy.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport { CustomRequestArgs, toRequestArgs } from './common';\nimport createContractTest from './contractTestTemplate';\nimport proxy from './proxy';\n\nPlugin.create<CustomRequestArgs>(requestArgs => ({\n\tschema: '0.1',\n\tversion: '0.4.0',\n\talias: 'jest',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test [partition]',\n\t\t\tdescription: 'Setup a directory as a partition to run Jest tests',\n\t\t\taliases: ['jest'],\n\t\t\thandler: 'proxy',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'partition',\n\t\t\t\t\tdescription: 'Name of the partition for these tests',\n\t\t\t\t\tdefaultValue: 'tests',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'init',\n\t\t\t\t\tshortFlag: 'i',\n\t\t\t\t\tdescription: 'Initializes the partition for Jest',\n\t\t\t\t\tboolean: true,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'testPattern',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdescription: 'Run test files that match the provided pattern',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t],\n\ttemplates: [\n\t\tTemplate.create({\n\t\t\ttemplate: 'contract-test',\n\t\t\tcommand: 'contract-test <michelsonArtifact>',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'michelsonArtifact',\n\t\t\t\t\tdescription: 'Name of the michelson contract (artifact) to generate tests for',\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'partition',\n\t\t\t\t\tdescription: 'Partition to place generated test suite',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefaultValue: toRequestArgs(requestArgs).config.jestTestsRootDir || 'tests',\n\t\t\t\t}),\n\t\t\t],\n\t\t\tdescription: 'Generate integration test for a contract',\n\t\t\thandler: createContractTest,\n\t\t}),\n\t],\n\tproxy,\n}), process.argv);\n","import { noop, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { LoadedConfig, RequestArgs, SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';\nimport { mkdir, stat, writeFile } from 'fs/promises';\nimport { defaults } from 'jest-config';\nimport { join, relative } from 'path';\n\nexport type DefaultConfig = typeof defaults;\n\nexport interface CustomConfig extends LoadedConfig.t {\n\treadonly jestTestsRootDir?: string;\n}\n\nexport interface CustomRequestArgs extends RequestArgs.t {\n\tconfig: CustomConfig;\n\tpartition?: string;\n}\n\nexport const toRequestArgs = (args: RequestArgs.t) => (args as CustomRequestArgs);\n\nexport const getDefaultConfig = (defaultConfig: DefaultConfig) => `\nmodule.exports = ${JSON.stringify(defaults, null, 4)}\n`;\n\nexport const ensureRootConfigExists = (projectDir: SanitizedAbsPath.t) => {\n\tconst jestRootConfig = getRootConfigAbspath(projectDir);\n\treturn stat(jestRootConfig)\n\t\t.catch(_ => writeFile(jestRootConfig, getDefaultConfig(defaults)))\n\t\t.then(_ => jestRootConfig);\n};\n\nexport const getRootConfigAbspath = (projectDir: SanitizedAbsPath.t) =>\n\tSanitizedAbsPath.create(\n\t\tjoin(projectDir, '.taq', 'jest.config.js'),\n\t);\n\nexport const getTestsRootDir = (config: CustomConfig) => {\n\treturn config.jestTestsRootDir || 'tests';\n};\n\nexport const toPartitionCfg = (partitionRelpath: SanitizedPath.t, rootConfigRelPath: SanitizedPath.t) => `\nconst parentConfig = require('${rootConfigRelPath}')\n\nmodule.exports = {\n ...parentConfig,\n roots: [\n \"${partitionRelpath}\"\n ]\n}\n`;\n\nexport const getPartitionAbspath = (partitionDir: string) => SanitizedAbsPath.create(partitionDir);\n\nexport const getPartitionConfigAbspath = (partitionDir: string) =>\n\tSanitizedAbsPath.create(join(partitionDir, 'jest.config.js'));\n\nexport const createPartition = async (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) =>\n\tensureRootConfigExists(projectDir)\n\t\t.then(_ => stat(partitionDir))\n\t\t.then(stats =>\n\t\t\tstats.isFile()\n\t\t\t\t? sendAsyncErr(`${partitionDir} is an invalid partition directory`)\n\t\t\t\t: stats\n\t\t)\n\t\t.catch(_ => mkdir(partitionDir, { recursive: true }))\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir))\n\t\t.then(partitionCfgAbsPath =>\n\t\t\tstat(partitionCfgAbsPath)\n\t\t\t\t.catch(_ =>\n\t\t\t\t\twriteFile(\n\t\t\t\t\t\tpartitionCfgAbsPath,\n\t\t\t\t\t\ttoPartitionCfg(\n\t\t\t\t\t\t\tSanitizedPath.create(relative(partitionDir, partitionDir)),\n\t\t\t\t\t\t\tSanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t)\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir));\n\nexport const ensurePartitionExists = (args: CustomRequestArgs) =>\n\targs.partition\n\t\t? createPartition(\n\t\t\tSanitizedAbsPath.create(join(args.projectDir, args.partition)),\n\t\t\targs.projectDir,\n\t\t)\n\t\t: createPartition(\n\t\t\tSanitizedAbsPath.create(\n\t\t\t\tjoin(args.projectDir, getTestsRootDir(args.config)),\n\t\t\t),\n\t\t\targs.projectDir,\n\t\t);\n","// import { normalizeContractName } from '@taqueria/plugin-contract-types/src/generator/contract-name';\nimport { sendAsyncRes } from '@taqueria/node-sdk';\nimport { generateContractTypesProcessContractFiles } from '@taqueria/plugin-contract-types/src/cli-process.js';\nimport {\n\tcreateTestingCodeGenerator,\n\tnormalizeContractName,\n} from '@taqueria/plugin-contract-types/src/generator/testing-code-generator.js';\nimport { readFile, stat, writeFile } from 'fs/promises';\nimport { basename, dirname, join } from 'path';\nimport { CustomRequestArgs, ensurePartitionExists, getPartitionAbspath, getTestsRootDir } from './common';\n\ntype Generator = ReturnType<typeof createTestingCodeGenerator>;\n\ninterface Opts extends CustomRequestArgs {\n\treadonly michelsonArtifact: string;\n\treadonly partition?: string;\n\treadonly name?: string;\n}\n\nconst getMichelsonAbspath = (parsedArgs: Opts) => join(parsedArgs.config.artifactsDir, parsedArgs.michelsonArtifact);\n\nconst ensureMichelsonExists = (parsedArgs: Opts) => {\n\tconst abspath = getMichelsonAbspath(parsedArgs);\n\treturn stat(abspath)\n\t\t.then(() => parsedArgs)\n\t\t.catch(() => Promise.reject(`${abspath} does not exist. Perhaps you need to run \"taq compile\"?`));\n};\n\nconst getPartition = (parsedArgs: Opts) => {\n\tconst partition = parsedArgs.partition ?? getTestsRootDir(parsedArgs.config);\n\treturn getPartitionAbspath(partition);\n};\n\nconst getTypesOutputAbspath = (parsedArgs: Opts) => join(getPartition(parsedArgs), 'types');\n\nconst generateContractTypes = (parsedArgs: Opts) =>\n\tgenerateContractTypesProcessContractFiles({\n\t\tinputTzContractDirectory: parsedArgs.config.artifactsDir,\n\t\tinputFiles: [getMichelsonAbspath(parsedArgs)],\n\t\toutputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),\n\t\tformat: 'tz',\n\t\ttypeAliasMode: 'file',\n\t}).then(_ => parsedArgs);\n\nconst getContractName = (parsedArgs: Opts) => parsedArgs.name ?? basename(parsedArgs.michelsonArtifact, '.tz');\n\nconst generateTestSuite = (parsedArgs: Opts) => {\n\tconst michelsonAbspath = getMichelsonAbspath(parsedArgs);\n\tconst contractName = getContractName(parsedArgs);\n\tconst partition = getPartition(parsedArgs);\n\tconst jestSuiteAbspath = join(partition, `${contractName}.ts`);\n\n\treturn readFile(michelsonAbspath, { encoding: 'utf-8' })\n\t\t.then(contractSource => ({ contractSource, contractFormat: 'tz' as const }))\n\t\t.then(createTestingCodeGenerator)\n\t\t.then(toJest(contractName))\n\t\t.then(contents => writeFile(jestSuiteAbspath, contents, { encoding: 'utf-8' }))\n\t\t.then(() => jestSuiteAbspath);\n};\n\nconst toJest = (contractName: string) =>\n\t(generator: Generator) => {\n\t\tconst methodCalls = generator.methods.map(m => ({\n\t\t\tname: m.name,\n\t\t\tmethodCall: generator.generateMethodCall({\n\t\t\t\tmethodName: m.name,\n\t\t\t\tformatting: {\n\t\t\t\t\tindent: 2,\n\t\t\t\t},\n\t\t\t}),\n\t\t\tstorageAccess: generator.generateStorageAccess({ storagePath: '' }),\n\t\t}));\n\t\treturn `\nimport { TezosToolkit } from '@taquito/taquito';\nimport { char2Bytes } from '@taquito/utils';\nimport { tas } from './types/type-aliases';\nimport { ${normalizeContractName(contractName)}ContractType as ContractType } from './types/${contractName}.types';\nimport { ${normalizeContractName(contractName)}Code as ContractCode } from './types/${contractName}.code';\n\ndescribe('${contractName}', () => {\n const Tezos = new TezosToolkit('RPC_URL');\n let contract: ContractType = undefined as unknown as ContractType;\n beforeAll(async () => {\n ${generator.generateOrigination({ formatting: { indent: 3 } }).code}\n });\n\n${\n\t\t\tmethodCalls.map(x => `\n it('should call ${x.name}', async () => {\n ${x.storageAccess.getStorageValueFunctionCode}\n const storageValueBefore = await ${x.storageAccess.getStorageValueFunctionName}();\n ${x.methodCall.code}\n const storageValueAfter = await ${x.storageAccess.getStorageValueFunctionName}();\n\n expect(storageValueAfter).toBe('');\n });\n`).join('')\n\t\t});\n`;\n\t};\n\nexport default (parsedArgs: Opts) => {\n\treturn ensureMichelsonExists(parsedArgs)\n\t\t.then(ensurePartitionExists)\n\t\t.then(() => parsedArgs)\n\t\t.then(generateContractTypes)\n\t\t.then(generateTestSuite)\n\t\t.then(outFile => sendAsyncRes(`Test suite generated: ${outFile}`));\n};\n","import { sendAsyncRes } from '@taqueria/node-sdk';\nimport { execa } from 'execa';\nimport { CustomRequestArgs, ensurePartitionExists } from './common';\n\ninterface Opts extends CustomRequestArgs {\n\treadonly init: boolean;\n\treadonly partition: string;\n\treadonly testPattern: string;\n}\n\nconst execCmd = (cmd: string, args: string[]) => {\n\tconst child = execa(cmd, args, {\n\t\tshell: true,\n\t\treject: false,\n\t\tenv: { FORCE_COLOR: 'true' },\n\t});\n\n\tchild.stdout?.pipe(process.stdout);\n\tchild.stderr?.pipe(process.stderr);\n\n\treturn child;\n};\n\nexport default async (args: Opts) => {\n\treturn ensurePartitionExists(args)\n\t\t.then(configAbsPath => {\n\t\t\tif (!args.init) {\n\t\t\t\tconst retval = args.testPattern\n\t\t\t\t\t? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern', args.testPattern])\n\t\t\t\t\t: execCmd('npx', ['jest', '-c', configAbsPath]);\n\t\t\t\treturn retval.then(child => {\n\t\t\t\t\tif (child.exitCode === 0) return;\n\t\t\t\t\telse process.exit(child.exitCode);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn sendAsyncRes('Initialized successfully.');\n\t\t});\n};\n"],"mappings":";;;AAAA,uBAA8D;;;ACA9D,sBAAiD;AACjD,mBAA2E;AAC3E,sBAAuC;AACvC,yBAAyB;AACzB,kBAA+B;AAaxB,IAAM,gBAAgB,CAAC,SAAyB;AAEhD,IAAM,mBAAmB,CAAC,kBAAiC;AAAA,mBAC/C,KAAK,UAAU,6BAAU,MAAM,CAAC;AAAA;AAG5C,IAAM,yBAAyB,CAAC,eAAmC;AACzE,QAAM,iBAAiB,qBAAqB,UAAU;AACtD,SAAO,0BAAK,cAAc,EACxB,MAAM,OAAK,+BAAU,gBAAgB,iBAAiB,2BAAQ,CAAC,CAAC,EAChE,KAAK,OAAK,cAAc;AAC3B;AAEO,IAAM,uBAAuB,CAAC,eACpC,8BAAiB,OAChB,sBAAK,YAAY,QAAQ,gBAAgB,CAC1C;AAEM,IAAM,kBAAkB,CAAC,WAAyB;AACxD,SAAO,OAAO,oBAAoB;AACnC;AA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C;AAAA,EACF;AAAA,EACA;AACD,IAAI,QAAQ,IAAI;","names":[]}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/index.js
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {execa as $d3MIr$execa} from "execa";
|
|
4
|
-
import {stat as $d3MIr$stat, writeFile as $d3MIr$writeFile, mkdir as $d3MIr$mkdir} from "fs/promises";
|
|
5
|
-
import {defaults as $d3MIr$defaults} from "jest-config";
|
|
6
|
-
import {join as $d3MIr$join, relative as $d3MIr$relative} from "path";
|
|
1
|
+
// index.ts
|
|
2
|
+
import { Option, Plugin, PositionalArg, Task, Template } from "@taqueria/node-sdk";
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
module.exports = ${JSON.stringify(
|
|
4
|
+
// common.ts
|
|
5
|
+
import { sendAsyncErr } from "@taqueria/node-sdk";
|
|
6
|
+
import { SanitizedAbsPath, SanitizedPath } from "@taqueria/node-sdk/types";
|
|
7
|
+
import { mkdir, stat, writeFile } from "fs/promises";
|
|
8
|
+
import { defaults } from "jest-config";
|
|
9
|
+
import { join, relative } from "path";
|
|
10
|
+
var toRequestArgs = (args) => args;
|
|
11
|
+
var getDefaultConfig = (defaultConfig) => `
|
|
12
|
+
module.exports = ${JSON.stringify(defaults, null, 4)}
|
|
17
13
|
`;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
var ensureRootConfigExists = (projectDir) => {
|
|
15
|
+
const jestRootConfig = getRootConfigAbspath(projectDir);
|
|
16
|
+
return stat(jestRootConfig).catch((_) => writeFile(jestRootConfig, getDefaultConfig(defaults))).then((_) => jestRootConfig);
|
|
21
17
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
var getRootConfigAbspath = (projectDir) => SanitizedAbsPath.create(join(projectDir, ".taq", "jest.config.js"));
|
|
19
|
+
var getTestsRootDir = (config) => {
|
|
20
|
+
return config.jestTestsRootDir || "tests";
|
|
25
21
|
};
|
|
26
|
-
|
|
22
|
+
var toPartitionCfg = (partitionRelpath, rootConfigRelPath) => `
|
|
27
23
|
const parentConfig = require('${rootConfigRelPath}')
|
|
28
24
|
|
|
29
25
|
module.exports = {
|
|
@@ -33,87 +29,174 @@ module.exports = {
|
|
|
33
29
|
]
|
|
34
30
|
}
|
|
35
31
|
`;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
32
|
+
var getPartitionAbspath = (partitionDir) => SanitizedAbsPath.create(partitionDir);
|
|
33
|
+
var getPartitionConfigAbspath = (partitionDir) => SanitizedAbsPath.create(join(partitionDir, "jest.config.js"));
|
|
34
|
+
var createPartition = async (partitionDir, projectDir) => ensureRootConfigExists(projectDir).then((_) => stat(partitionDir)).then((stats) => stats.isFile() ? sendAsyncErr(`${partitionDir} is an invalid partition directory`) : stats).catch((_) => mkdir(partitionDir, { recursive: true })).then((_) => getPartitionConfigAbspath(partitionDir)).then((partitionCfgAbsPath) => stat(partitionCfgAbsPath).catch((_) => writeFile(partitionCfgAbsPath, toPartitionCfg(SanitizedPath.create(relative(partitionDir, partitionDir)), SanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))))))).then((_) => getPartitionConfigAbspath(partitionDir));
|
|
35
|
+
var ensurePartitionExists = (args) => args.partition ? createPartition(SanitizedAbsPath.create(join(args.projectDir, args.partition)), args.projectDir) : createPartition(SanitizedAbsPath.create(join(args.projectDir, getTestsRootDir(args.config))), args.projectDir);
|
|
36
|
+
|
|
37
|
+
// contractTestTemplate.ts
|
|
38
|
+
import { sendAsyncRes as sendAsyncRes2 } from "@taqueria/node-sdk";
|
|
39
|
+
import { generateContractTypesProcessContractFiles } from "@taqueria/plugin-contract-types/src/cli-process.js";
|
|
40
|
+
import {
|
|
41
|
+
createTestingCodeGenerator,
|
|
42
|
+
normalizeContractName
|
|
43
|
+
} from "@taqueria/plugin-contract-types/src/generator/testing-code-generator.js";
|
|
44
|
+
import { readFile, stat as stat2, writeFile as writeFile2 } from "fs/promises";
|
|
45
|
+
import { basename, join as join2 } from "path";
|
|
46
|
+
var getMichelsonAbspath = (parsedArgs) => join2(parsedArgs.config.artifactsDir, parsedArgs.michelsonArtifact);
|
|
47
|
+
var ensureMichelsonExists = (parsedArgs) => {
|
|
48
|
+
const abspath = getMichelsonAbspath(parsedArgs);
|
|
49
|
+
return stat2(abspath).then(() => parsedArgs).catch(() => Promise.reject(`${abspath} does not exist. Perhaps you need to run "taq compile"?`));
|
|
53
50
|
};
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!opts.init) {
|
|
58
|
-
const retval = opts.testPattern ? $74485658d1dbcd36$var$execCmd("npx", [
|
|
59
|
-
"jest",
|
|
60
|
-
"-c",
|
|
61
|
-
configAbsPath,
|
|
62
|
-
"--testPathPattern",
|
|
63
|
-
opts.testPattern
|
|
64
|
-
]) : $74485658d1dbcd36$var$execCmd("npx", [
|
|
65
|
-
"jest",
|
|
66
|
-
"-c",
|
|
67
|
-
configAbsPath
|
|
68
|
-
]);
|
|
69
|
-
return retval.then((child)=>{
|
|
70
|
-
if (child.exitCode === 0) return;
|
|
71
|
-
else process.exit(child.exitCode);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
return (0, $d3MIr$sendAsyncRes)("Initialized successfully.");
|
|
75
|
-
});
|
|
51
|
+
var getPartition = (parsedArgs) => {
|
|
52
|
+
const partition = parsedArgs.partition ?? getTestsRootDir(parsedArgs.config);
|
|
53
|
+
return getPartitionAbspath(partition);
|
|
76
54
|
};
|
|
55
|
+
var getTypesOutputAbspath = (parsedArgs) => join2(getPartition(parsedArgs), "types");
|
|
56
|
+
var generateContractTypes = (parsedArgs) => generateContractTypesProcessContractFiles({
|
|
57
|
+
inputTzContractDirectory: parsedArgs.config.artifactsDir,
|
|
58
|
+
inputFiles: [getMichelsonAbspath(parsedArgs)],
|
|
59
|
+
outputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),
|
|
60
|
+
format: "tz",
|
|
61
|
+
typeAliasMode: "file"
|
|
62
|
+
}).then((_) => parsedArgs);
|
|
63
|
+
var getContractName = (parsedArgs) => parsedArgs.name ?? basename(parsedArgs.michelsonArtifact, ".tz");
|
|
64
|
+
var generateTestSuite = (parsedArgs) => {
|
|
65
|
+
const michelsonAbspath = getMichelsonAbspath(parsedArgs);
|
|
66
|
+
const contractName = getContractName(parsedArgs);
|
|
67
|
+
const partition = getPartition(parsedArgs);
|
|
68
|
+
const jestSuiteAbspath = join2(partition, `${contractName}.ts`);
|
|
69
|
+
return readFile(michelsonAbspath, { encoding: "utf-8" }).then((contractSource) => ({ contractSource, contractFormat: "tz" })).then(createTestingCodeGenerator).then(toJest(contractName)).then((contents) => writeFile2(jestSuiteAbspath, contents, { encoding: "utf-8" })).then(() => jestSuiteAbspath);
|
|
70
|
+
};
|
|
71
|
+
var toJest = (contractName) => (generator) => {
|
|
72
|
+
const methodCalls = generator.methods.map((m) => ({
|
|
73
|
+
name: m.name,
|
|
74
|
+
methodCall: generator.generateMethodCall({
|
|
75
|
+
methodName: m.name,
|
|
76
|
+
formatting: {
|
|
77
|
+
indent: 2
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
80
|
+
storageAccess: generator.generateStorageAccess({ storagePath: "" })
|
|
81
|
+
}));
|
|
82
|
+
return `
|
|
83
|
+
import { TezosToolkit } from '@taquito/taquito';
|
|
84
|
+
import { char2Bytes } from '@taquito/utils';
|
|
85
|
+
import { tas } from './types/type-aliases';
|
|
86
|
+
import { ${normalizeContractName(contractName)}ContractType as ContractType } from './types/${contractName}.types';
|
|
87
|
+
import { ${normalizeContractName(contractName)}Code as ContractCode } from './types/${contractName}.code';
|
|
77
88
|
|
|
89
|
+
describe('${contractName}', () => {
|
|
90
|
+
const Tezos = new TezosToolkit('RPC_URL');
|
|
91
|
+
let contract: ContractType = undefined as unknown as ContractType;
|
|
92
|
+
beforeAll(async () => {
|
|
93
|
+
${generator.generateOrigination({ formatting: { indent: 3 } }).code}
|
|
94
|
+
});
|
|
78
95
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
task: "test",
|
|
86
|
-
command: "test [partition]",
|
|
87
|
-
description: "Setup a directory as a partition to run Jest tests",
|
|
88
|
-
aliases: [
|
|
89
|
-
"jest"
|
|
90
|
-
],
|
|
91
|
-
handler: "proxy",
|
|
92
|
-
positionals: [
|
|
93
|
-
(0, $d3MIr$PositionalArg).create({
|
|
94
|
-
placeholder: "partition",
|
|
95
|
-
description: "Name of the partition for these tests",
|
|
96
|
-
defaultValue: "tests",
|
|
97
|
-
type: "string"
|
|
98
|
-
}),
|
|
99
|
-
],
|
|
100
|
-
options: [
|
|
101
|
-
(0, $d3MIr$Option).create({
|
|
102
|
-
flag: "init",
|
|
103
|
-
shortFlag: "i",
|
|
104
|
-
description: "Initializes the partition for Jest",
|
|
105
|
-
boolean: true
|
|
106
|
-
}),
|
|
107
|
-
(0, $d3MIr$Option).create({
|
|
108
|
-
flag: "testPattern",
|
|
109
|
-
shortFlag: "t",
|
|
110
|
-
description: "Run test files that match the provided pattern"
|
|
111
|
-
}),
|
|
112
|
-
]
|
|
113
|
-
}),
|
|
114
|
-
],
|
|
115
|
-
proxy: $74485658d1dbcd36$export$2e2bcd8739ae039
|
|
116
|
-
}), process.argv);
|
|
96
|
+
${methodCalls.map((x) => `
|
|
97
|
+
it('should call ${x.name}', async () => {
|
|
98
|
+
${x.storageAccess.getStorageValueFunctionCode}
|
|
99
|
+
const storageValueBefore = await ${x.storageAccess.getStorageValueFunctionName}();
|
|
100
|
+
${x.methodCall.code}
|
|
101
|
+
const storageValueAfter = await ${x.storageAccess.getStorageValueFunctionName}();
|
|
117
102
|
|
|
103
|
+
expect(storageValueAfter).toBe('');
|
|
104
|
+
});
|
|
105
|
+
`).join("")});
|
|
106
|
+
`;
|
|
107
|
+
};
|
|
108
|
+
var contractTestTemplate_default = (parsedArgs) => {
|
|
109
|
+
return ensureMichelsonExists(parsedArgs).then(ensurePartitionExists).then(() => parsedArgs).then(generateContractTypes).then(generateTestSuite).then((outFile) => sendAsyncRes2(`Test suite generated: ${outFile}`));
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// proxy.ts
|
|
113
|
+
import { sendAsyncRes as sendAsyncRes3 } from "@taqueria/node-sdk";
|
|
114
|
+
import { execa } from "execa";
|
|
115
|
+
var execCmd = (cmd, args) => {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
const child = execa(cmd, args, {
|
|
118
|
+
shell: true,
|
|
119
|
+
reject: false,
|
|
120
|
+
env: { FORCE_COLOR: "true" }
|
|
121
|
+
});
|
|
122
|
+
(_a = child.stdout) == null ? void 0 : _a.pipe(process.stdout);
|
|
123
|
+
(_b = child.stderr) == null ? void 0 : _b.pipe(process.stderr);
|
|
124
|
+
return child;
|
|
125
|
+
};
|
|
126
|
+
var proxy_default = async (args) => {
|
|
127
|
+
return ensurePartitionExists(args).then((configAbsPath) => {
|
|
128
|
+
if (!args.init) {
|
|
129
|
+
const retval = args.testPattern ? execCmd("npx", ["jest", "-c", configAbsPath, "--testPathPattern", args.testPattern]) : execCmd("npx", ["jest", "-c", configAbsPath]);
|
|
130
|
+
return retval.then((child) => {
|
|
131
|
+
if (child.exitCode === 0)
|
|
132
|
+
return;
|
|
133
|
+
else
|
|
134
|
+
process.exit(child.exitCode);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return sendAsyncRes3("Initialized successfully.");
|
|
138
|
+
});
|
|
139
|
+
};
|
|
118
140
|
|
|
119
|
-
|
|
141
|
+
// index.ts
|
|
142
|
+
Plugin.create((requestArgs) => ({
|
|
143
|
+
schema: "0.1",
|
|
144
|
+
version: "0.4.0",
|
|
145
|
+
alias: "jest",
|
|
146
|
+
tasks: [
|
|
147
|
+
Task.create({
|
|
148
|
+
task: "test",
|
|
149
|
+
command: "test [partition]",
|
|
150
|
+
description: "Setup a directory as a partition to run Jest tests",
|
|
151
|
+
aliases: ["jest"],
|
|
152
|
+
handler: "proxy",
|
|
153
|
+
positionals: [
|
|
154
|
+
PositionalArg.create({
|
|
155
|
+
placeholder: "partition",
|
|
156
|
+
description: "Name of the partition for these tests",
|
|
157
|
+
defaultValue: "tests",
|
|
158
|
+
type: "string"
|
|
159
|
+
})
|
|
160
|
+
],
|
|
161
|
+
options: [
|
|
162
|
+
Option.create({
|
|
163
|
+
flag: "init",
|
|
164
|
+
shortFlag: "i",
|
|
165
|
+
description: "Initializes the partition for Jest",
|
|
166
|
+
boolean: true
|
|
167
|
+
}),
|
|
168
|
+
Option.create({
|
|
169
|
+
flag: "testPattern",
|
|
170
|
+
shortFlag: "t",
|
|
171
|
+
description: "Run test files that match the provided pattern"
|
|
172
|
+
})
|
|
173
|
+
]
|
|
174
|
+
})
|
|
175
|
+
],
|
|
176
|
+
templates: [
|
|
177
|
+
Template.create({
|
|
178
|
+
template: "contract-test",
|
|
179
|
+
command: "contract-test <michelsonArtifact>",
|
|
180
|
+
positionals: [
|
|
181
|
+
PositionalArg.create({
|
|
182
|
+
placeholder: "michelsonArtifact",
|
|
183
|
+
description: "Name of the michelson contract (artifact) to generate tests for",
|
|
184
|
+
required: true,
|
|
185
|
+
type: "string"
|
|
186
|
+
})
|
|
187
|
+
],
|
|
188
|
+
options: [
|
|
189
|
+
Option.create({
|
|
190
|
+
flag: "partition",
|
|
191
|
+
description: "Partition to place generated test suite",
|
|
192
|
+
type: "string",
|
|
193
|
+
defaultValue: toRequestArgs(requestArgs).config.jestTestsRootDir || "tests"
|
|
194
|
+
})
|
|
195
|
+
],
|
|
196
|
+
description: "Generate integration test for a contract",
|
|
197
|
+
handler: contractTestTemplate_default
|
|
198
|
+
})
|
|
199
|
+
],
|
|
200
|
+
proxy: proxy_default
|
|
201
|
+
}), process.argv);
|
|
202
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;ACAA;;;;;;AAoBA,MAAM,sCAAgB,GAAG,CAAC,aAA4B,GAAK,CAAC;iBAC3C,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA,GAAA,eAAQ,CAAA,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACrD,CAAC,AAAC;AAEF,MAAM,4CAAsB,GAAG,CAAC,UAA8B,GAAK;IAClE,MAAM,cAAc,GAAG,0CAAoB,CAAC,UAAU,CAAC,AAAC;IACxD,OAAO,CAAA,GAAA,WAAI,CAAA,CAAC,cAAc,CAAC,CACzB,KAAK,CAAC,CAAA,CAAC,GAAI,CAAA,GAAA,gBAAS,CAAA,CAAC,cAAc,EAAE,sCAAgB,CAAC,CAAA,GAAA,eAAQ,CAAA,CAAC,CAAC,CAAC,CACjE,IAAI,CAAC,CAAA,CAAC,GAAI,cAAc,CAAC,CAAC;CAC5B,AAAC;AAEF,MAAM,0CAAoB,GAAG,CAAC,UAA8B,GAC3D,CAAA,GAAA,uBAAgB,CAAA,CAAC,MAAM,CACtB,CAAA,GAAA,WAAI,CAAA,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAC1C,AAAC;AAEH,MAAM,qCAAe,GAAG,CAAC,MAAoB,GAAK;IACjD,OAAO,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAC;CAC1C,AAAC;AAEF,MAAM,oCAAc,GAAG,CAAC,gBAAiC,EAAE,iBAAkC,GAAK,CAAC;8BACrE,EAAE,iBAAiB,CAAC;;;;;SAKzC,EAAE,gBAAgB,CAAC;;;AAG5B,CAAC,A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;wBACnB,SAAS,EAAE,GAAG;wBACd,WAAW,EAAE,gDAAgD;qBAC7D,CAAC;iBACF;aACD,CAAC;SACF;eACD,wCAAK;KACL,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-jest/index.ts","taqueria-plugin-jest/proxy.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';\nimport proxy from './proxy';\n\nPlugin.create(() => ({\n\tschema: '0.1',\n\tversion: '0.4.0',\n\talias: 'jest',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test [partition]',\n\t\t\tdescription: 'Setup a directory as a partition to run Jest tests',\n\t\t\taliases: ['jest'],\n\t\t\thandler: 'proxy',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'partition',\n\t\t\t\t\tdescription: 'Name of the partition for these tests',\n\t\t\t\t\tdefaultValue: 'tests',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'init',\n\t\t\t\t\tshortFlag: 'i',\n\t\t\t\t\tdescription: 'Initializes the partition for Jest',\n\t\t\t\t\tboolean: true,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'testPattern',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdescription: 'Run test files that match the provided pattern',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t],\n\tproxy,\n}), process.argv);\n","import { noop, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { LoadedConfig, RequestArgs, SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';\nimport { execa } from 'execa';\nimport { mkdir, stat, writeFile } from 'fs/promises';\nimport { defaults } from 'jest-config';\nimport { join, relative } from 'path';\n\ntype DefaultConfig = typeof defaults;\n\ninterface CustomConfig extends LoadedConfig.t {\n\treadonly jestTestsRootDir?: string;\n}\n\ninterface Opts extends RequestArgs.ProxyRequestArgs {\n\treadonly config: CustomConfig;\n\treadonly init: boolean;\n\treadonly partition: string;\n\treadonly testPattern: string;\n}\n\nconst getDefaultConfig = (defaultConfig: DefaultConfig) => `\nmodule.exports = ${JSON.stringify(defaults, null, 4)}\n`;\n\nconst ensureRootConfigExists = (projectDir: SanitizedAbsPath.t) => {\n\tconst jestRootConfig = getRootConfigAbspath(projectDir);\n\treturn stat(jestRootConfig)\n\t\t.catch(_ => writeFile(jestRootConfig, getDefaultConfig(defaults)))\n\t\t.then(_ => jestRootConfig);\n};\n\nconst getRootConfigAbspath = (projectDir: SanitizedAbsPath.t) =>\n\tSanitizedAbsPath.create(\n\t\tjoin(projectDir, '.taq', 'jest.config.js'),\n\t);\n\nconst getTestsRootDir = (config: CustomConfig) => {\n\treturn config.jestTestsRootDir || 'tests';\n};\n\nconst toPartitionCfg = (partitionRelpath: SanitizedPath.t, rootConfigRelPath: SanitizedPath.t) => `\nconst parentConfig = require('${rootConfigRelPath}')\n\nmodule.exports = {\n ...parentConfig,\n roots: [\n \"${partitionRelpath}\"\n ]\n}\n`;\n\nconst getPartitionAbspath = (partitionDir: string) => SanitizedAbsPath.create(partitionDir);\n\nconst getPartitionConfigAbspath = (partitionDir: string) =>\n\tSanitizedAbsPath.create(join(partitionDir, 'jest.config.js'));\n\nconst createPartition = async (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) =>\n\tensureRootConfigExists(projectDir)\n\t\t.then(_ => stat(partitionDir))\n\t\t.then(stats =>\n\t\t\tstats.isFile()\n\t\t\t\t? sendAsyncErr(`${partitionDir} is an invalid partition directory`)\n\t\t\t\t: stats\n\t\t)\n\t\t.catch(_ => mkdir(partitionDir, { recursive: true }))\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir))\n\t\t.then(partitionCfgAbsPath =>\n\t\t\tstat(partitionCfgAbsPath)\n\t\t\t\t.catch(_ =>\n\t\t\t\t\twriteFile(\n\t\t\t\t\t\tpartitionCfgAbsPath,\n\t\t\t\t\t\ttoPartitionCfg(\n\t\t\t\t\t\t\tSanitizedPath.create(relative(partitionDir, partitionDir)),\n\t\t\t\t\t\t\tSanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t)\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir));\n\nconst ensurePartitionExists = (args: Opts) =>\n\targs.partition\n\t\t? createPartition(\n\t\t\tSanitizedAbsPath.create(join(args.projectDir, args.partition)),\n\t\t\targs.projectDir,\n\t\t)\n\t\t: createPartition(\n\t\t\tSanitizedAbsPath.create(\n\t\t\t\tjoin(args.projectDir, getTestsRootDir(args.config)),\n\t\t\t),\n\t\t\targs.projectDir,\n\t\t);\n\nconst execCmd = (cmd: string, args: string[]) => {\n\tconst child = execa(cmd, args, {\n\t\tshell: true,\n\t\treject: false,\n\t\tenv: { FORCE_COLOR: 'true' },\n\t});\n\n\tchild.stdout?.pipe(process.stdout);\n\tchild.stderr?.pipe(process.stderr);\n\n\treturn child;\n};\n\nexport default async (args: RequestArgs.ProxyRequestArgs) => {\n\tconst opts = args as Opts;\n\n\treturn ensurePartitionExists(opts)\n\t\t.then(configAbsPath => {\n\t\t\tif (!opts.init) {\n\t\t\t\tconst retval = opts.testPattern\n\t\t\t\t\t? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern', opts.testPattern])\n\t\t\t\t\t: execCmd('npx', ['jest', '-c', configAbsPath]);\n\t\t\t\treturn retval.then(child => {\n\t\t\t\t\tif (child.exitCode === 0) return;\n\t\t\t\t\telse process.exit(child.exitCode);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn sendAsyncRes('Initialized successfully.');\n\t\t});\n};\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
|
|
1
|
+
{"version":3,"sources":["index.ts","common.ts","contractTestTemplate.ts","proxy.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport { CustomRequestArgs, toRequestArgs } from './common';\nimport createContractTest from './contractTestTemplate';\nimport proxy from './proxy';\n\nPlugin.create<CustomRequestArgs>(requestArgs => ({\n\tschema: '0.1',\n\tversion: '0.4.0',\n\talias: 'jest',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test [partition]',\n\t\t\tdescription: 'Setup a directory as a partition to run Jest tests',\n\t\t\taliases: ['jest'],\n\t\t\thandler: 'proxy',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'partition',\n\t\t\t\t\tdescription: 'Name of the partition for these tests',\n\t\t\t\t\tdefaultValue: 'tests',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'init',\n\t\t\t\t\tshortFlag: 'i',\n\t\t\t\t\tdescription: 'Initializes the partition for Jest',\n\t\t\t\t\tboolean: true,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'testPattern',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdescription: 'Run test files that match the provided pattern',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t],\n\ttemplates: [\n\t\tTemplate.create({\n\t\t\ttemplate: 'contract-test',\n\t\t\tcommand: 'contract-test <michelsonArtifact>',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'michelsonArtifact',\n\t\t\t\t\tdescription: 'Name of the michelson contract (artifact) to generate tests for',\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'partition',\n\t\t\t\t\tdescription: 'Partition to place generated test suite',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefaultValue: toRequestArgs(requestArgs).config.jestTestsRootDir || 'tests',\n\t\t\t\t}),\n\t\t\t],\n\t\t\tdescription: 'Generate integration test for a contract',\n\t\t\thandler: createContractTest,\n\t\t}),\n\t],\n\tproxy,\n}), process.argv);\n","import { noop, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { LoadedConfig, RequestArgs, SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';\nimport { mkdir, stat, writeFile } from 'fs/promises';\nimport { defaults } from 'jest-config';\nimport { join, relative } from 'path';\n\nexport type DefaultConfig = typeof defaults;\n\nexport interface CustomConfig extends LoadedConfig.t {\n\treadonly jestTestsRootDir?: string;\n}\n\nexport interface CustomRequestArgs extends RequestArgs.t {\n\tconfig: CustomConfig;\n\tpartition?: string;\n}\n\nexport const toRequestArgs = (args: RequestArgs.t) => (args as CustomRequestArgs);\n\nexport const getDefaultConfig = (defaultConfig: DefaultConfig) => `\nmodule.exports = ${JSON.stringify(defaults, null, 4)}\n`;\n\nexport const ensureRootConfigExists = (projectDir: SanitizedAbsPath.t) => {\n\tconst jestRootConfig = getRootConfigAbspath(projectDir);\n\treturn stat(jestRootConfig)\n\t\t.catch(_ => writeFile(jestRootConfig, getDefaultConfig(defaults)))\n\t\t.then(_ => jestRootConfig);\n};\n\nexport const getRootConfigAbspath = (projectDir: SanitizedAbsPath.t) =>\n\tSanitizedAbsPath.create(\n\t\tjoin(projectDir, '.taq', 'jest.config.js'),\n\t);\n\nexport const getTestsRootDir = (config: CustomConfig) => {\n\treturn config.jestTestsRootDir || 'tests';\n};\n\nexport const toPartitionCfg = (partitionRelpath: SanitizedPath.t, rootConfigRelPath: SanitizedPath.t) => `\nconst parentConfig = require('${rootConfigRelPath}')\n\nmodule.exports = {\n ...parentConfig,\n roots: [\n \"${partitionRelpath}\"\n ]\n}\n`;\n\nexport const getPartitionAbspath = (partitionDir: string) => SanitizedAbsPath.create(partitionDir);\n\nexport const getPartitionConfigAbspath = (partitionDir: string) =>\n\tSanitizedAbsPath.create(join(partitionDir, 'jest.config.js'));\n\nexport const createPartition = async (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) =>\n\tensureRootConfigExists(projectDir)\n\t\t.then(_ => stat(partitionDir))\n\t\t.then(stats =>\n\t\t\tstats.isFile()\n\t\t\t\t? sendAsyncErr(`${partitionDir} is an invalid partition directory`)\n\t\t\t\t: stats\n\t\t)\n\t\t.catch(_ => mkdir(partitionDir, { recursive: true }))\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir))\n\t\t.then(partitionCfgAbsPath =>\n\t\t\tstat(partitionCfgAbsPath)\n\t\t\t\t.catch(_ =>\n\t\t\t\t\twriteFile(\n\t\t\t\t\t\tpartitionCfgAbsPath,\n\t\t\t\t\t\ttoPartitionCfg(\n\t\t\t\t\t\t\tSanitizedPath.create(relative(partitionDir, partitionDir)),\n\t\t\t\t\t\t\tSanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t)\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir));\n\nexport const ensurePartitionExists = (args: CustomRequestArgs) =>\n\targs.partition\n\t\t? createPartition(\n\t\t\tSanitizedAbsPath.create(join(args.projectDir, args.partition)),\n\t\t\targs.projectDir,\n\t\t)\n\t\t: createPartition(\n\t\t\tSanitizedAbsPath.create(\n\t\t\t\tjoin(args.projectDir, getTestsRootDir(args.config)),\n\t\t\t),\n\t\t\targs.projectDir,\n\t\t);\n","// import { normalizeContractName } from '@taqueria/plugin-contract-types/src/generator/contract-name';\nimport { sendAsyncRes } from '@taqueria/node-sdk';\nimport { generateContractTypesProcessContractFiles } from '@taqueria/plugin-contract-types/src/cli-process.js';\nimport {\n\tcreateTestingCodeGenerator,\n\tnormalizeContractName,\n} from '@taqueria/plugin-contract-types/src/generator/testing-code-generator.js';\nimport { readFile, stat, writeFile } from 'fs/promises';\nimport { basename, dirname, join } from 'path';\nimport { CustomRequestArgs, ensurePartitionExists, getPartitionAbspath, getTestsRootDir } from './common';\n\ntype Generator = ReturnType<typeof createTestingCodeGenerator>;\n\ninterface Opts extends CustomRequestArgs {\n\treadonly michelsonArtifact: string;\n\treadonly partition?: string;\n\treadonly name?: string;\n}\n\nconst getMichelsonAbspath = (parsedArgs: Opts) => join(parsedArgs.config.artifactsDir, parsedArgs.michelsonArtifact);\n\nconst ensureMichelsonExists = (parsedArgs: Opts) => {\n\tconst abspath = getMichelsonAbspath(parsedArgs);\n\treturn stat(abspath)\n\t\t.then(() => parsedArgs)\n\t\t.catch(() => Promise.reject(`${abspath} does not exist. Perhaps you need to run \"taq compile\"?`));\n};\n\nconst getPartition = (parsedArgs: Opts) => {\n\tconst partition = parsedArgs.partition ?? getTestsRootDir(parsedArgs.config);\n\treturn getPartitionAbspath(partition);\n};\n\nconst getTypesOutputAbspath = (parsedArgs: Opts) => join(getPartition(parsedArgs), 'types');\n\nconst generateContractTypes = (parsedArgs: Opts) =>\n\tgenerateContractTypesProcessContractFiles({\n\t\tinputTzContractDirectory: parsedArgs.config.artifactsDir,\n\t\tinputFiles: [getMichelsonAbspath(parsedArgs)],\n\t\toutputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),\n\t\tformat: 'tz',\n\t\ttypeAliasMode: 'file',\n\t}).then(_ => parsedArgs);\n\nconst getContractName = (parsedArgs: Opts) => parsedArgs.name ?? basename(parsedArgs.michelsonArtifact, '.tz');\n\nconst generateTestSuite = (parsedArgs: Opts) => {\n\tconst michelsonAbspath = getMichelsonAbspath(parsedArgs);\n\tconst contractName = getContractName(parsedArgs);\n\tconst partition = getPartition(parsedArgs);\n\tconst jestSuiteAbspath = join(partition, `${contractName}.ts`);\n\n\treturn readFile(michelsonAbspath, { encoding: 'utf-8' })\n\t\t.then(contractSource => ({ contractSource, contractFormat: 'tz' as const }))\n\t\t.then(createTestingCodeGenerator)\n\t\t.then(toJest(contractName))\n\t\t.then(contents => writeFile(jestSuiteAbspath, contents, { encoding: 'utf-8' }))\n\t\t.then(() => jestSuiteAbspath);\n};\n\nconst toJest = (contractName: string) =>\n\t(generator: Generator) => {\n\t\tconst methodCalls = generator.methods.map(m => ({\n\t\t\tname: m.name,\n\t\t\tmethodCall: generator.generateMethodCall({\n\t\t\t\tmethodName: m.name,\n\t\t\t\tformatting: {\n\t\t\t\t\tindent: 2,\n\t\t\t\t},\n\t\t\t}),\n\t\t\tstorageAccess: generator.generateStorageAccess({ storagePath: '' }),\n\t\t}));\n\t\treturn `\nimport { TezosToolkit } from '@taquito/taquito';\nimport { char2Bytes } from '@taquito/utils';\nimport { tas } from './types/type-aliases';\nimport { ${normalizeContractName(contractName)}ContractType as ContractType } from './types/${contractName}.types';\nimport { ${normalizeContractName(contractName)}Code as ContractCode } from './types/${contractName}.code';\n\ndescribe('${contractName}', () => {\n const Tezos = new TezosToolkit('RPC_URL');\n let contract: ContractType = undefined as unknown as ContractType;\n beforeAll(async () => {\n ${generator.generateOrigination({ formatting: { indent: 3 } }).code}\n });\n\n${\n\t\t\tmethodCalls.map(x => `\n it('should call ${x.name}', async () => {\n ${x.storageAccess.getStorageValueFunctionCode}\n const storageValueBefore = await ${x.storageAccess.getStorageValueFunctionName}();\n ${x.methodCall.code}\n const storageValueAfter = await ${x.storageAccess.getStorageValueFunctionName}();\n\n expect(storageValueAfter).toBe('');\n });\n`).join('')\n\t\t});\n`;\n\t};\n\nexport default (parsedArgs: Opts) => {\n\treturn ensureMichelsonExists(parsedArgs)\n\t\t.then(ensurePartitionExists)\n\t\t.then(() => parsedArgs)\n\t\t.then(generateContractTypes)\n\t\t.then(generateTestSuite)\n\t\t.then(outFile => sendAsyncRes(`Test suite generated: ${outFile}`));\n};\n","import { sendAsyncRes } from '@taqueria/node-sdk';\nimport { execa } from 'execa';\nimport { CustomRequestArgs, ensurePartitionExists } from './common';\n\ninterface Opts extends CustomRequestArgs {\n\treadonly init: boolean;\n\treadonly partition: string;\n\treadonly testPattern: string;\n}\n\nconst execCmd = (cmd: string, args: string[]) => {\n\tconst child = execa(cmd, args, {\n\t\tshell: true,\n\t\treject: false,\n\t\tenv: { FORCE_COLOR: 'true' },\n\t});\n\n\tchild.stdout?.pipe(process.stdout);\n\tchild.stderr?.pipe(process.stderr);\n\n\treturn child;\n};\n\nexport default async (args: Opts) => {\n\treturn ensurePartitionExists(args)\n\t\t.then(configAbsPath => {\n\t\t\tif (!args.init) {\n\t\t\t\tconst retval = args.testPattern\n\t\t\t\t\t? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern', args.testPattern])\n\t\t\t\t\t: execCmd('npx', ['jest', '-c', configAbsPath]);\n\t\t\t\treturn retval.then(child => {\n\t\t\t\t\tif (child.exitCode === 0) return;\n\t\t\t\t\telse process.exit(child.exitCode);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn sendAsyncRes('Initialized successfully.');\n\t\t});\n};\n"],"mappings":";AAAA;;;ACAA;AACA;AACA;AACA;AACA;AAaO,IAAM,gBAAgB,CAAC,SAAyB;AAEhD,IAAM,mBAAmB,CAAC,kBAAiC;AAAA,mBAC/C,KAAK,UAAU,UAAU,MAAM,CAAC;AAAA;AAG5C,IAAM,yBAAyB,CAAC,eAAmC;AACzE,QAAM,iBAAiB,qBAAqB,UAAU;AACtD,SAAO,KAAK,cAAc,EACxB,MAAM,OAAK,UAAU,gBAAgB,iBAAiB,QAAQ,CAAC,CAAC,EAChE,KAAK,OAAK,cAAc;AAC3B;AAEO,IAAM,uBAAuB,CAAC,eACpC,iBAAiB,OAChB,KAAK,YAAY,QAAQ,gBAAgB,CAC1C;AAEM,IAAM,kBAAkB,CAAC,WAAyB;AACxD,SAAO,OAAO,oBAAoB;AACnC;AAEO,IAAM,iBAAiB,CAAC,kBAAmC,sBAAuC;AAAA,gCACzE;AAAA;AAAA;AAAA;AAAA;AAAA,WAKrB;AAAA;AAAA;AAAA;AAKJ,IAAM,sBAAsB,CAAC,iBAAyB,iBAAiB,OAAO,YAAY;AAE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AAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,IACN,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,SAAS,CAAC,MAAM;AAAA,MAChB,SAAS;AAAA,MACT,aAAa;AAAA,QACZ,cAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,UACb,cAAc;AAAA,UACd,MAAM;AAAA,QACP,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACR,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,aAAa;AAAA,UACb,SAAS;AAAA,QACV,CAAC;AAAA,QACD,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,EACF;AAAA,EACA,WAAW;AAAA,IACV,SAAS,OAAO;AAAA,MACf,UAAU;AAAA,MACV,SAAS;AAAA,MACT,aAAa;AAAA,QACZ,cAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,UACb,UAAU;AAAA,UACV,MAAM;AAAA,QACP,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACR,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aAAa;AAAA,UACb,MAAM;AAAA,UACN,cAAc,cAAc,WAAW,EAAE,OAAO,oBAAoB;AAAA,QACrE,CAAC;AAAA,MACF;AAAA,MACA,aAAa;AAAA,MACb,SAAS;AAAA,IACV,CAAC;AAAA,EACF;AAAA,EACA;AACD,IAAI,QAAQ,IAAI;","names":[]}
|
package/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Option, Plugin, PositionalArg, Task } from '@taqueria/node-sdk';
|
|
1
|
+
import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';
|
|
2
|
+
import { CustomRequestArgs, toRequestArgs } from './common';
|
|
3
|
+
import createContractTest from './contractTestTemplate';
|
|
2
4
|
import proxy from './proxy';
|
|
3
5
|
|
|
4
|
-
Plugin.create(
|
|
6
|
+
Plugin.create<CustomRequestArgs>(requestArgs => ({
|
|
5
7
|
schema: '0.1',
|
|
6
8
|
version: '0.4.0',
|
|
7
9
|
alias: 'jest',
|
|
@@ -35,5 +37,29 @@ Plugin.create(() => ({
|
|
|
35
37
|
],
|
|
36
38
|
}),
|
|
37
39
|
],
|
|
40
|
+
templates: [
|
|
41
|
+
Template.create({
|
|
42
|
+
template: 'contract-test',
|
|
43
|
+
command: 'contract-test <michelsonArtifact>',
|
|
44
|
+
positionals: [
|
|
45
|
+
PositionalArg.create({
|
|
46
|
+
placeholder: 'michelsonArtifact',
|
|
47
|
+
description: 'Name of the michelson contract (artifact) to generate tests for',
|
|
48
|
+
required: true,
|
|
49
|
+
type: 'string',
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
options: [
|
|
53
|
+
Option.create({
|
|
54
|
+
flag: 'partition',
|
|
55
|
+
description: 'Partition to place generated test suite',
|
|
56
|
+
type: 'string',
|
|
57
|
+
defaultValue: toRequestArgs(requestArgs).config.jestTestsRootDir || 'tests',
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
description: 'Generate integration test for a contract',
|
|
61
|
+
handler: createContractTest,
|
|
62
|
+
}),
|
|
63
|
+
],
|
|
38
64
|
proxy,
|
|
39
65
|
}), process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/plugin-jest",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-852-a3ccfd4e",
|
|
4
|
+
"main": "index.cjs",
|
|
5
|
+
"module": "index.js",
|
|
6
|
+
"source": "index.ts",
|
|
7
|
+
"type": "module",
|
|
4
8
|
"description": "A plugin for Taqueria providing automated testing using the Jest Testing Framework",
|
|
5
9
|
"keywords": [
|
|
6
10
|
"taqueria",
|
|
@@ -12,21 +16,11 @@
|
|
|
12
16
|
"ecadlabs",
|
|
13
17
|
"tezos"
|
|
14
18
|
],
|
|
15
|
-
"targets": {
|
|
16
|
-
"default": {
|
|
17
|
-
"source": "./index.ts",
|
|
18
|
-
"distDir": "./",
|
|
19
|
-
"context": "node",
|
|
20
|
-
"isLibrary": true,
|
|
21
|
-
"outputFormat": "esmodule"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
19
|
"scripts": {
|
|
25
|
-
"build": "npx tsc -noEmit -p ./tsconfig.json && npx
|
|
20
|
+
"build": "npx tsc -noEmit -p ./tsconfig.json && npx tsup"
|
|
26
21
|
},
|
|
27
22
|
"author": "ECAD Labs",
|
|
28
23
|
"license": "Apache-2.0",
|
|
29
|
-
"type": "module",
|
|
30
24
|
"repository": {
|
|
31
25
|
"type": "git",
|
|
32
26
|
"url": "https://github.com/ecadlabs/taqueria.git",
|
|
@@ -34,6 +28,7 @@
|
|
|
34
28
|
},
|
|
35
29
|
"dependencies": {
|
|
36
30
|
"@taqueria/node-sdk": "^0.8.7",
|
|
31
|
+
"@taqueria/plugin-contract-types": "^0.8.7",
|
|
37
32
|
"async-retry": "^1.3.3",
|
|
38
33
|
"execa": "^6.1.0",
|
|
39
34
|
"fast-glob": "^3.2.7",
|
|
@@ -44,7 +39,23 @@
|
|
|
44
39
|
"devDependencies": {
|
|
45
40
|
"@types/async-retry": "^1.3.3",
|
|
46
41
|
"@types/jest": "^27.5.1",
|
|
47
|
-
"
|
|
42
|
+
"tsup": "^6.1.3",
|
|
48
43
|
"typescript": "4.7.2"
|
|
44
|
+
},
|
|
45
|
+
"tsup": {
|
|
46
|
+
"entry": [
|
|
47
|
+
"index.ts"
|
|
48
|
+
],
|
|
49
|
+
"sourcemap": true,
|
|
50
|
+
"target": "node16",
|
|
51
|
+
"outDir": "./",
|
|
52
|
+
"dts": true,
|
|
53
|
+
"clean": false,
|
|
54
|
+
"skipNodeModulesBundle": true,
|
|
55
|
+
"platform": "node",
|
|
56
|
+
"format": [
|
|
57
|
+
"esm",
|
|
58
|
+
"cjs"
|
|
59
|
+
]
|
|
49
60
|
}
|
|
50
61
|
}
|
package/proxy.ts
CHANGED
|
@@ -1,96 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LoadedConfig, RequestArgs, SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';
|
|
1
|
+
import { sendAsyncRes } from '@taqueria/node-sdk';
|
|
3
2
|
import { execa } from 'execa';
|
|
4
|
-
import {
|
|
5
|
-
import { defaults } from 'jest-config';
|
|
6
|
-
import { join, relative } from 'path';
|
|
3
|
+
import { CustomRequestArgs, ensurePartitionExists } from './common';
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
interface CustomConfig extends LoadedConfig.t {
|
|
11
|
-
readonly jestTestsRootDir?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface Opts extends RequestArgs.ProxyRequestArgs {
|
|
15
|
-
readonly config: CustomConfig;
|
|
5
|
+
interface Opts extends CustomRequestArgs {
|
|
16
6
|
readonly init: boolean;
|
|
17
7
|
readonly partition: string;
|
|
18
8
|
readonly testPattern: string;
|
|
19
9
|
}
|
|
20
10
|
|
|
21
|
-
const getDefaultConfig = (defaultConfig: DefaultConfig) => `
|
|
22
|
-
module.exports = ${JSON.stringify(defaults, null, 4)}
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
const ensureRootConfigExists = (projectDir: SanitizedAbsPath.t) => {
|
|
26
|
-
const jestRootConfig = getRootConfigAbspath(projectDir);
|
|
27
|
-
return stat(jestRootConfig)
|
|
28
|
-
.catch(_ => writeFile(jestRootConfig, getDefaultConfig(defaults)))
|
|
29
|
-
.then(_ => jestRootConfig);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const getRootConfigAbspath = (projectDir: SanitizedAbsPath.t) =>
|
|
33
|
-
SanitizedAbsPath.create(
|
|
34
|
-
join(projectDir, '.taq', 'jest.config.js'),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const getTestsRootDir = (config: CustomConfig) => {
|
|
38
|
-
return config.jestTestsRootDir || 'tests';
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const toPartitionCfg = (partitionRelpath: SanitizedPath.t, rootConfigRelPath: SanitizedPath.t) => `
|
|
42
|
-
const parentConfig = require('${rootConfigRelPath}')
|
|
43
|
-
|
|
44
|
-
module.exports = {
|
|
45
|
-
...parentConfig,
|
|
46
|
-
roots: [
|
|
47
|
-
"${partitionRelpath}"
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
`;
|
|
51
|
-
|
|
52
|
-
const getPartitionAbspath = (partitionDir: string) => SanitizedAbsPath.create(partitionDir);
|
|
53
|
-
|
|
54
|
-
const getPartitionConfigAbspath = (partitionDir: string) =>
|
|
55
|
-
SanitizedAbsPath.create(join(partitionDir, 'jest.config.js'));
|
|
56
|
-
|
|
57
|
-
const createPartition = async (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) =>
|
|
58
|
-
ensureRootConfigExists(projectDir)
|
|
59
|
-
.then(_ => stat(partitionDir))
|
|
60
|
-
.then(stats =>
|
|
61
|
-
stats.isFile()
|
|
62
|
-
? sendAsyncErr(`${partitionDir} is an invalid partition directory`)
|
|
63
|
-
: stats
|
|
64
|
-
)
|
|
65
|
-
.catch(_ => mkdir(partitionDir, { recursive: true }))
|
|
66
|
-
.then(_ => getPartitionConfigAbspath(partitionDir))
|
|
67
|
-
.then(partitionCfgAbsPath =>
|
|
68
|
-
stat(partitionCfgAbsPath)
|
|
69
|
-
.catch(_ =>
|
|
70
|
-
writeFile(
|
|
71
|
-
partitionCfgAbsPath,
|
|
72
|
-
toPartitionCfg(
|
|
73
|
-
SanitizedPath.create(relative(partitionDir, partitionDir)),
|
|
74
|
-
SanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),
|
|
75
|
-
),
|
|
76
|
-
)
|
|
77
|
-
)
|
|
78
|
-
)
|
|
79
|
-
.then(_ => getPartitionConfigAbspath(partitionDir));
|
|
80
|
-
|
|
81
|
-
const ensurePartitionExists = (args: Opts) =>
|
|
82
|
-
args.partition
|
|
83
|
-
? createPartition(
|
|
84
|
-
SanitizedAbsPath.create(join(args.projectDir, args.partition)),
|
|
85
|
-
args.projectDir,
|
|
86
|
-
)
|
|
87
|
-
: createPartition(
|
|
88
|
-
SanitizedAbsPath.create(
|
|
89
|
-
join(args.projectDir, getTestsRootDir(args.config)),
|
|
90
|
-
),
|
|
91
|
-
args.projectDir,
|
|
92
|
-
);
|
|
93
|
-
|
|
94
11
|
const execCmd = (cmd: string, args: string[]) => {
|
|
95
12
|
const child = execa(cmd, args, {
|
|
96
13
|
shell: true,
|
|
@@ -104,14 +21,12 @@ const execCmd = (cmd: string, args: string[]) => {
|
|
|
104
21
|
return child;
|
|
105
22
|
};
|
|
106
23
|
|
|
107
|
-
export default async (args:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return ensurePartitionExists(opts)
|
|
24
|
+
export default async (args: Opts) => {
|
|
25
|
+
return ensurePartitionExists(args)
|
|
111
26
|
.then(configAbsPath => {
|
|
112
|
-
if (!
|
|
113
|
-
const retval =
|
|
114
|
-
? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern',
|
|
27
|
+
if (!args.init) {
|
|
28
|
+
const retval = args.testPattern
|
|
29
|
+
? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern', args.testPattern])
|
|
115
30
|
: execCmd('npx', ['jest', '-c', configAbsPath]);
|
|
116
31
|
return retval.then(child => {
|
|
117
32
|
if (child.exitCode === 0) return;
|
package/tsconfig.json
CHANGED
|
@@ -31,7 +31,10 @@
|
|
|
31
31
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
32
32
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
33
33
|
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
|
|
34
|
-
|
|
34
|
+
"types": [
|
|
35
|
+
"node",
|
|
36
|
+
"jest"
|
|
37
|
+
], /* Specify type package names to be included without being referenced in a source file. */
|
|
35
38
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
36
39
|
// "resolveJsonModule": true, /* Enable importing .json files */
|
|
37
40
|
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
|
|
@@ -68,13 +71,13 @@
|
|
|
68
71
|
|
|
69
72
|
/* Interop Constraints */
|
|
70
73
|
"isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
71
|
-
"allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
74
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
72
75
|
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */
|
|
73
76
|
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
74
77
|
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
75
78
|
|
|
76
79
|
/* Type Checking */
|
|
77
|
-
"strict": true
|
|
80
|
+
"strict": true /* Enable all strict type-checking options. */
|
|
78
81
|
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
|
|
79
82
|
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
|
|
80
83
|
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
@@ -96,6 +99,6 @@
|
|
|
96
99
|
|
|
97
100
|
/* Completeness */
|
|
98
101
|
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
99
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
102
|
+
// "skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
100
103
|
}
|
|
101
104
|
}
|