yeoman-test 11.5.1 → 11.5.3
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/helpers.d.ts +1 -1
- package/dist/run-context.d.ts +3 -3
- package/dist/run-context.js +6 -3
- package/dist/run-result.d.ts +4 -4
- package/dist/run-result.js +2 -2
- package/package.json +2 -2
- package/types/type-helpers.d.ts +3 -11
package/dist/helpers.d.ts
CHANGED
|
@@ -126,7 +126,7 @@ export declare class YeomanTest {
|
|
|
126
126
|
* @param {Object} - Options to be passed to the environment
|
|
127
127
|
* const env = createTestEnv(require('yeoman-environment').createEnv);
|
|
128
128
|
*/
|
|
129
|
-
createTestEnv(environmentContructor?: CreateEnv, options?: EnvironmentOptions): Promise<
|
|
129
|
+
createTestEnv(environmentContructor?: CreateEnv, options?: EnvironmentOptions): Promise<DefaultEnvironmentApi>;
|
|
130
130
|
/**
|
|
131
131
|
* Creates a TestAdapter using helpers default options.
|
|
132
132
|
*/
|
package/dist/run-context.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ type EnvironmentOptions = BaseEnvironmentOptions & {
|
|
|
37
37
|
createEnv?: CreateEnvironment;
|
|
38
38
|
};
|
|
39
39
|
export declare class RunContextBase<GeneratorType extends BaseGenerator = DefaultGeneratorApi> extends EventEmitter {
|
|
40
|
-
readonly mockedGenerators: Record<string,
|
|
40
|
+
readonly mockedGenerators: Record<string, unknown>;
|
|
41
41
|
env: DefaultEnvironmentApi;
|
|
42
42
|
generator: GeneratorType;
|
|
43
43
|
readonly settings: RunContextSettings;
|
|
@@ -153,14 +153,14 @@ export declare class RunContextBase<GeneratorType extends BaseGenerator = Defaul
|
|
|
153
153
|
* @param {Function} [cb] - callback who'll receive the folder path as argument
|
|
154
154
|
* @return {this} run context instance
|
|
155
155
|
*/
|
|
156
|
-
withEnvironment(callback: (this: this, environment: DefaultEnvironmentApi) => DefaultEnvironmentApi | void): this;
|
|
156
|
+
withEnvironment(callback: (this: this, environment: DefaultEnvironmentApi) => DefaultEnvironmentApi | void | Promise<DefaultEnvironmentApi | void>): this;
|
|
157
157
|
/**
|
|
158
158
|
* Customize enviroment run method.
|
|
159
159
|
*
|
|
160
160
|
* @param callback
|
|
161
161
|
* @return {this} run context instance
|
|
162
162
|
*/
|
|
163
|
-
withEnvironmentRun(callback: (this: this, env: DefaultEnvironmentApi, gen: GeneratorType) => void): this;
|
|
163
|
+
withEnvironmentRun(callback: (this: this, env: DefaultEnvironmentApi, gen: GeneratorType) => void | Promise<void>): this;
|
|
164
164
|
/**
|
|
165
165
|
* Run lookup on the environment.
|
|
166
166
|
*
|
package/dist/run-context.js
CHANGED
|
@@ -263,9 +263,10 @@ export class RunContextBase extends EventEmitter {
|
|
|
263
263
|
}
|
|
264
264
|
// Add options as both kebab and camel case. This is to stay backward compatibles with
|
|
265
265
|
// the switch we made to meow for options parsing.
|
|
266
|
+
const optionsAny = options;
|
|
266
267
|
for (const key of Object.keys(options)) {
|
|
267
|
-
|
|
268
|
-
|
|
268
|
+
optionsAny[camelCase(key)] = optionsAny[key];
|
|
269
|
+
optionsAny[kebabCase(key)] = optionsAny[key];
|
|
269
270
|
}
|
|
270
271
|
this.options = { ...this.options, ...options };
|
|
271
272
|
return this;
|
|
@@ -290,7 +291,9 @@ export class RunContextBase extends EventEmitter {
|
|
|
290
291
|
*/
|
|
291
292
|
withAnswers(answers, options) {
|
|
292
293
|
this.answers = { ...this.answers, ...answers };
|
|
293
|
-
|
|
294
|
+
if (options) {
|
|
295
|
+
this.withAdapterOptions(options);
|
|
296
|
+
}
|
|
294
297
|
return this;
|
|
295
298
|
}
|
|
296
299
|
/**
|
package/dist/run-result.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export type RunResultOptions<GeneratorType extends BaseGenerator> = {
|
|
|
34
34
|
/**
|
|
35
35
|
* The mocked generators of the context.
|
|
36
36
|
*/
|
|
37
|
-
mockedGenerators: Record<string,
|
|
37
|
+
mockedGenerators: Record<string, unknown>;
|
|
38
38
|
spawnStub?: any;
|
|
39
39
|
settings: RunContextSettings;
|
|
40
40
|
helpers: YeomanTest;
|
|
@@ -50,7 +50,7 @@ export default class RunResult<GeneratorType extends BaseGenerator = BaseGenerat
|
|
|
50
50
|
oldCwd: string;
|
|
51
51
|
memFs: Store<MemFsEditorFile>;
|
|
52
52
|
fs: MemFsEditor;
|
|
53
|
-
mockedGenerators:
|
|
53
|
+
mockedGenerators: Record<string, unknown>;
|
|
54
54
|
options: RunResultOptions<GeneratorType>;
|
|
55
55
|
spawnStub?: any;
|
|
56
56
|
readonly askedQuestions: AskedQuestions;
|
|
@@ -217,9 +217,9 @@ export default class RunResult<GeneratorType extends BaseGenerator = BaseGenerat
|
|
|
217
217
|
/**
|
|
218
218
|
* Get the generator mock
|
|
219
219
|
* @param generator - the namespace of the mocked generator
|
|
220
|
-
* @returns the generator mock
|
|
220
|
+
* @returns the generator mock, by default is the mock property of node:test's mock.
|
|
221
221
|
*/
|
|
222
|
-
getGeneratorMock
|
|
222
|
+
getGeneratorMock<MockType = ReturnType<typeof mock.fn>['mock']>(generator: string): MockType;
|
|
223
223
|
/**
|
|
224
224
|
* Get the number of times a mocked generator was composed
|
|
225
225
|
* @param generator - the namespace of the mocked generator
|
package/dist/run-result.js
CHANGED
|
@@ -271,14 +271,14 @@ export default class RunResult {
|
|
|
271
271
|
/**
|
|
272
272
|
* Get the generator mock
|
|
273
273
|
* @param generator - the namespace of the mocked generator
|
|
274
|
-
* @returns the generator mock
|
|
274
|
+
* @returns the generator mock, by default is the mock property of node:test's mock.
|
|
275
275
|
*/
|
|
276
276
|
getGeneratorMock(generator) {
|
|
277
277
|
const mockedGenerator = this.mockedGenerators[generator];
|
|
278
278
|
if (!mockedGenerator) {
|
|
279
279
|
throw new Error(`Generator ${generator} is not mocked`);
|
|
280
280
|
}
|
|
281
|
-
return mockedGenerator.mock;
|
|
281
|
+
return (mockedGenerator.mock ?? mockedGenerator);
|
|
282
282
|
}
|
|
283
283
|
/**
|
|
284
284
|
* Get the number of times a mocked generator was composed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yeoman-test",
|
|
3
|
-
"version": "11.5.
|
|
3
|
+
"version": "11.5.3",
|
|
4
4
|
"description": "Test utilities for Yeoman generators",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yeoman",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"fix": "prettier . --write && eslint . --fix",
|
|
41
41
|
"precommit": "lint-staged",
|
|
42
42
|
"prepare": "npm run build && husky",
|
|
43
|
-
"pretest": "eslint .",
|
|
43
|
+
"pretest": "eslint . && tsc -p tsconfig.spec.json",
|
|
44
44
|
"test": "vitest run --coverage"
|
|
45
45
|
},
|
|
46
46
|
"config": {
|
package/types/type-helpers.d.ts
CHANGED
|
@@ -3,15 +3,7 @@ import type GeneratorImplementation from 'yeoman-generator';
|
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
import type EnvironmentImplementation from 'yeoman-environment';
|
|
6
|
-
import type {
|
|
6
|
+
import type { IsAny } from 'type-fest';
|
|
7
7
|
|
|
8
|
-
export type DefaultGeneratorApi =
|
|
9
|
-
|
|
10
|
-
BaseGenerator,
|
|
11
|
-
typeof GeneratorImplementation extends BaseGenerator ? typeof GeneratorImplementation : BaseGenerator
|
|
12
|
-
>;
|
|
13
|
-
export type DefaultEnvironmentApi = IfAny<
|
|
14
|
-
typeof EnvironmentImplementation,
|
|
15
|
-
BaseEnvironment,
|
|
16
|
-
typeof EnvironmentImplementation extends BaseEnvironment ? typeof EnvironmentImplementation : BaseEnvironment
|
|
17
|
-
>;
|
|
8
|
+
export type DefaultGeneratorApi = IsAny<GeneratorImplementation> extends true ? BaseGenerator : GeneratorImplementation;
|
|
9
|
+
export type DefaultEnvironmentApi = IsAny<EnvironmentImplementation> extends true ? BaseEnvironment : EnvironmentImplementation;
|