@virmator/plugin-testing 14.26.1 → 14.27.0
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/dist/test-plugin.d.ts +8 -1
- package/dist/test-plugin.js +5 -4
- package/package.json +2 -2
package/dist/test-plugin.d.ts
CHANGED
|
@@ -28,4 +28,11 @@ export type TestPluginOptions = PartialWithUndefined<{
|
|
|
28
28
|
beforeCleanupCallback: (cwd: string) => MaybePromise<void>;
|
|
29
29
|
}>;
|
|
30
30
|
/** Tests a virmator plugin and saves a snapshot of the results. */
|
|
31
|
-
export declare function testPlugin(shouldPass
|
|
31
|
+
export declare function testPlugin({ shouldPass, context, plugin, cliCommand, cwd, options, }: Readonly<{
|
|
32
|
+
shouldPass: boolean;
|
|
33
|
+
context: UniversalTestContext;
|
|
34
|
+
plugin: Readonly<VirmatorPlugin> | ReadonlyArray<Readonly<VirmatorPlugin>>;
|
|
35
|
+
cliCommand: string;
|
|
36
|
+
cwd: string;
|
|
37
|
+
options?: TestPluginOptions | undefined;
|
|
38
|
+
}>): Promise<void>;
|
package/dist/test-plugin.js
CHANGED
|
@@ -27,8 +27,9 @@ const defaultContentsExcludeList = [
|
|
|
27
27
|
wrapper: sep,
|
|
28
28
|
}),
|
|
29
29
|
];
|
|
30
|
+
const defaultLogTransform = (logType, arg) => arg;
|
|
30
31
|
/** Tests a virmator plugin and saves a snapshot of the results. */
|
|
31
|
-
export async function testPlugin(shouldPass, context, plugin, cliCommand, cwd,
|
|
32
|
+
export async function testPlugin({ shouldPass, context, plugin, cliCommand, cwd, options = {}, }) {
|
|
32
33
|
assertTestContext(context, TestEnv.Node);
|
|
33
34
|
const logs = {};
|
|
34
35
|
const logger = createLogger({
|
|
@@ -40,7 +41,7 @@ export async function testPlugin(shouldPass, context, plugin, cliCommand, cwd, {
|
|
|
40
41
|
},
|
|
41
42
|
});
|
|
42
43
|
const fullExcludeList = [
|
|
43
|
-
...excludeContents,
|
|
44
|
+
...(options.excludeContents ?? []),
|
|
44
45
|
...defaultContentsExcludeList,
|
|
45
46
|
];
|
|
46
47
|
const readDir = await findClosestPackageDir({
|
|
@@ -69,7 +70,7 @@ export async function testPlugin(shouldPass, context, plugin, cliCommand, cwd, {
|
|
|
69
70
|
else if (error) {
|
|
70
71
|
console.error(error);
|
|
71
72
|
}
|
|
72
|
-
await beforeCleanupCallback?.(cwd);
|
|
73
|
+
await options.beforeCleanupCallback?.(cwd);
|
|
73
74
|
const contentsAfter = await readAllDirContents(readDir, {
|
|
74
75
|
recursive: true,
|
|
75
76
|
excludeList: fullExcludeList,
|
|
@@ -77,7 +78,7 @@ export async function testPlugin(shouldPass, context, plugin, cliCommand, cwd, {
|
|
|
77
78
|
const contentsDiff = diffObjects(contentsBefore, contentsAfter)[1];
|
|
78
79
|
const result = {
|
|
79
80
|
logs: mapObjectValues(logs, (logType, logs) => {
|
|
80
|
-
return toPosixPath(logTransform(logType, logs.join('\n'))).replaceAll('\r', '');
|
|
81
|
+
return toPosixPath((options.logTransform ?? defaultLogTransform)(logType, logs.join('\n'))).replaceAll('\r', '');
|
|
81
82
|
}),
|
|
82
83
|
cwd: toPosixPath(relative(monoRepoDir, cwd)),
|
|
83
84
|
contentsDiff,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virmator/plugin-testing",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.27.0",
|
|
4
4
|
"description": "Testing for virmator plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"virmator",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@augment-vir/common": "^31.72.1",
|
|
36
36
|
"@augment-vir/node": "^31.72.1",
|
|
37
37
|
"@augment-vir/test": "^31.72.1",
|
|
38
|
-
"@virmator/core": "^14.
|
|
38
|
+
"@virmator/core": "^14.27.0",
|
|
39
39
|
"type-fest": "^5.7.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|