yeoman-test 8.0.0-alpha.2 → 8.0.0-beta.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/helpers.d.ts +7 -7
- package/dist/helpers.js +12 -8
- package/dist/run-context.d.ts +5 -7
- package/dist/run-result.d.ts +3 -2
- package/dist/test-context.d.ts +1 -2
- package/package.json +3 -3
package/dist/helpers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import GeneratorImplementation
|
|
1
|
+
import GeneratorImplementation from 'yeoman-generator';
|
|
2
2
|
import Environment from 'yeoman-environment';
|
|
3
3
|
import type { createEnv } from 'yeoman-environment';
|
|
4
|
-
import type { BaseEnvironmentOptions, BaseGenerator, GetGeneratorConstructor, PromptAnswers } from '@yeoman/types';
|
|
4
|
+
import type { BaseEnvironmentOptions, BaseGenerator, GeneratorBaseOptions, GetGeneratorConstructor, GetGeneratorOptions, PromptAnswers } from '@yeoman/types';
|
|
5
5
|
import type { SinonSpiedInstance } from 'sinon';
|
|
6
6
|
import { type DummyPromptOptions } from './adapter.js';
|
|
7
7
|
import RunContext, { BasicRunContext, type RunContextSettings } from './run-context.js';
|
|
@@ -17,7 +17,7 @@ export type GeneratorFactory<GenParameter extends BaseGenerator = GeneratorImple
|
|
|
17
17
|
export declare class YeomanTest {
|
|
18
18
|
settings?: RunContextSettings;
|
|
19
19
|
environmentOptions?: BaseEnvironmentOptions;
|
|
20
|
-
generatorOptions?:
|
|
20
|
+
generatorOptions?: GeneratorBaseOptions;
|
|
21
21
|
/**
|
|
22
22
|
* @deprecated
|
|
23
23
|
* Create a function that will clean up the test directory,
|
|
@@ -64,7 +64,7 @@ export declare class YeomanTest {
|
|
|
64
64
|
* @param generator - a Yeoman generator
|
|
65
65
|
* @param localConfig - localConfig - should look just like if called config.getAll()
|
|
66
66
|
*/
|
|
67
|
-
mockLocalConfig(generator: BaseGenerator, localConfig:
|
|
67
|
+
mockLocalConfig(generator: BaseGenerator, localConfig: any): void;
|
|
68
68
|
/**
|
|
69
69
|
* Create a mocked generator
|
|
70
70
|
*/
|
|
@@ -72,7 +72,7 @@ export declare class YeomanTest {
|
|
|
72
72
|
/**
|
|
73
73
|
* Create a simple, dummy generator
|
|
74
74
|
*/
|
|
75
|
-
createDummyGenerator<GenParameter extends BaseGenerator = GeneratorImplementation>(Generator?: GetGeneratorConstructor<GenParameter>, contents?: Record<string, (...args: any[]) => void>): GenParameter;
|
|
75
|
+
createDummyGenerator<GenParameter extends BaseGenerator = GeneratorImplementation>(Generator?: GetGeneratorConstructor<GenParameter>, contents?: Record<string, (...args: any[]) => void>): new (...args: any[]) => GenParameter;
|
|
76
76
|
/**
|
|
77
77
|
* Create a generator, using the given dependencies and controller arguments
|
|
78
78
|
* Dependecies can be path (autodiscovery) or an array [{generator}, {name}]
|
|
@@ -92,7 +92,7 @@ export declare class YeomanTest {
|
|
|
92
92
|
* ];
|
|
93
93
|
* var angular = createGenerator('angular:app', deps);
|
|
94
94
|
*/
|
|
95
|
-
createGenerator<GeneratorType extends BaseGenerator = GeneratorImplementation>(name: string, dependencies: Dependency[], args?: string[], options?:
|
|
95
|
+
createGenerator<GeneratorType extends BaseGenerator = GeneratorImplementation>(name: string, dependencies: Dependency[], args?: string[], options?: GetGeneratorOptions<GeneratorType>, localConfigOnly?: boolean): Promise<GeneratorType>;
|
|
96
96
|
/**
|
|
97
97
|
* @deprecated
|
|
98
98
|
* Register a list of dependent generators into the provided env.
|
|
@@ -145,7 +145,7 @@ export declare class YeomanTest {
|
|
|
145
145
|
* Prepare temporary dir without generator support.
|
|
146
146
|
* Generator and environment will be undefined.
|
|
147
147
|
*/
|
|
148
|
-
prepareTemporaryDir(settings?: RunContextSettings): BasicRunContext
|
|
148
|
+
prepareTemporaryDir(settings?: RunContextSettings): BasicRunContext<BaseGenerator>;
|
|
149
149
|
}
|
|
150
150
|
declare const defaultHelpers: YeomanTest;
|
|
151
151
|
export default defaultHelpers;
|
package/dist/helpers.js
CHANGED
|
@@ -109,13 +109,14 @@ export class YeomanTest {
|
|
|
109
109
|
/**
|
|
110
110
|
* Create a mocked generator
|
|
111
111
|
*/
|
|
112
|
-
createMockedGenerator(GeneratorClass =
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
createMockedGenerator(GeneratorClass = GeneratorImplementation) {
|
|
113
|
+
class MockedGenerator extends GeneratorClass {
|
|
114
|
+
}
|
|
115
|
+
const generator = sinonSpy(MockedGenerator);
|
|
115
116
|
for (const methodName of ['run', 'queueTasks', 'runWithOptions', 'queueOwnTasks']) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
117
|
+
Object.defineProperty(MockedGenerator.prototype, methodName, {
|
|
118
|
+
value: sinonStub(),
|
|
119
|
+
});
|
|
119
120
|
}
|
|
120
121
|
return generator;
|
|
121
122
|
}
|
|
@@ -129,8 +130,11 @@ export class YeomanTest {
|
|
|
129
130
|
}) {
|
|
130
131
|
class DummyGenerator extends Generator {
|
|
131
132
|
constructor(...args) {
|
|
132
|
-
|
|
133
|
-
args[
|
|
133
|
+
const optIndex = Array.isArray(args[0]) ? 1 : 0;
|
|
134
|
+
args[optIndex] = args[optIndex] ?? {};
|
|
135
|
+
const options = args[optIndex];
|
|
136
|
+
options.namespace = options.namespace ?? 'dummy';
|
|
137
|
+
options.resolved = options.resolved ?? 'dummy';
|
|
134
138
|
super(...args);
|
|
135
139
|
}
|
|
136
140
|
}
|
package/dist/run-context.d.ts
CHANGED
|
@@ -4,8 +4,6 @@ import { type Store } from 'mem-fs';
|
|
|
4
4
|
import type { BaseEnvironmentOptions, BaseGenerator, GetGeneratorConstructor, GetGeneratorOptions, PromptAnswers } from '@yeoman/types';
|
|
5
5
|
import type Environment from 'yeoman-environment';
|
|
6
6
|
import { type LookupOptions } from 'yeoman-environment';
|
|
7
|
-
import type GeneratorImplementation from 'yeoman-generator';
|
|
8
|
-
import type { StorageRecord } from 'yeoman-generator';
|
|
9
7
|
import { type MemFsEditor, type VinylMemFsEditorFile } from 'mem-fs-editor';
|
|
10
8
|
import RunResult, { type RunResultOptions } from './run-result.js';
|
|
11
9
|
import { type Dependency, type YeomanTest, type GeneratorFactory } from './helpers.js';
|
|
@@ -35,11 +33,11 @@ export type RunContextSettings = {
|
|
|
35
33
|
namespace?: string;
|
|
36
34
|
};
|
|
37
35
|
type PromiseRunResult<GeneratorType extends BaseGenerator> = Promise<RunResult<GeneratorType>>;
|
|
38
|
-
type MockedGeneratorFactory
|
|
36
|
+
type MockedGeneratorFactory<GenParameter extends BaseGenerator = BaseGenerator> = (GeneratorClass?: GetGeneratorConstructor<GenParameter>) => GenParameter;
|
|
39
37
|
type EnvOptions = BaseEnvironmentOptions & {
|
|
40
38
|
createEnv?: any;
|
|
41
39
|
};
|
|
42
|
-
export declare class RunContextBase<GeneratorType extends BaseGenerator =
|
|
40
|
+
export declare class RunContextBase<GeneratorType extends BaseGenerator = BaseGenerator> extends EventEmitter {
|
|
43
41
|
readonly mockedGenerators: Record<string, BaseGenerator>;
|
|
44
42
|
env: Environment;
|
|
45
43
|
generator: GeneratorType;
|
|
@@ -221,7 +219,7 @@ export declare class RunContextBase<GeneratorType extends BaseGenerator = Genera
|
|
|
221
219
|
* Mock the local configuration with the provided config
|
|
222
220
|
* @param localConfig - should look just like if called config.getAll()
|
|
223
221
|
*/
|
|
224
|
-
withLocalConfig(localConfig:
|
|
222
|
+
withLocalConfig(localConfig: any): this;
|
|
225
223
|
/**
|
|
226
224
|
* Don't reset mem-fs state cleared to aggregate snapshots from multiple runs.
|
|
227
225
|
*/
|
|
@@ -294,13 +292,13 @@ export declare class RunContextBase<GeneratorType extends BaseGenerator = Genera
|
|
|
294
292
|
*/
|
|
295
293
|
private setDir;
|
|
296
294
|
}
|
|
297
|
-
export default class RunContext<GeneratorType extends BaseGenerator =
|
|
295
|
+
export default class RunContext<GeneratorType extends BaseGenerator = BaseGenerator> extends RunContextBase<GeneratorType> implements Promise<RunResult<GeneratorType>> {
|
|
298
296
|
then<TResult1 = RunResult<GeneratorType>, TResult2 = never>(onfulfilled?: ((value: RunResult<GeneratorType>) => TResult1 | PromiseLike<TResult1>) | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined): Promise<TResult1 | TResult2>;
|
|
299
297
|
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined): Promise<RunResult<GeneratorType> | TResult>;
|
|
300
298
|
finally(onfinally?: (() => void) | undefined): Promise<RunResult<GeneratorType>>;
|
|
301
299
|
get [Symbol.toStringTag](): string;
|
|
302
300
|
}
|
|
303
|
-
export declare class BasicRunContext extends RunContext {
|
|
301
|
+
export declare class BasicRunContext<GeneratorType extends BaseGenerator = BaseGenerator> extends RunContext<GeneratorType> {
|
|
304
302
|
run(): PromiseRunResult<any>;
|
|
305
303
|
}
|
|
306
304
|
export {};
|
package/dist/run-result.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export type RunResultOptions<GeneratorType extends BaseGenerator> = {
|
|
|
37
37
|
/**
|
|
38
38
|
* This class provides utilities for testing generated content.
|
|
39
39
|
*/
|
|
40
|
-
export default class RunResult<GeneratorType extends BaseGenerator =
|
|
40
|
+
export default class RunResult<GeneratorType extends BaseGenerator = BaseGenerator> {
|
|
41
41
|
env: any;
|
|
42
42
|
generator: GeneratorType;
|
|
43
43
|
cwd: string;
|
|
@@ -66,7 +66,8 @@ export default class RunResult<GeneratorType extends BaseGenerator = GeneratorIm
|
|
|
66
66
|
* @returns {Object}
|
|
67
67
|
*/
|
|
68
68
|
getStateSnapshot(filter?: any): Record<string, {
|
|
69
|
-
stateCleared
|
|
69
|
+
stateCleared?: string;
|
|
70
|
+
state?: string;
|
|
70
71
|
}>;
|
|
71
72
|
/**
|
|
72
73
|
* Either dumps the contents of the specified files or the name and the contents of each file to the console.
|
package/dist/test-context.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { BaseGenerator } from '@yeoman/types';
|
|
2
1
|
import type RunContext from './run-context.js';
|
|
3
2
|
import type RunResult from './run-result.js';
|
|
4
3
|
declare class TestContext {
|
|
5
|
-
runResult?: RunResult
|
|
4
|
+
runResult?: RunResult;
|
|
6
5
|
private runContext?;
|
|
7
6
|
startNewContext(runContext?: RunContext<any>): void;
|
|
8
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yeoman-test",
|
|
3
|
-
"version": "8.0.0-
|
|
3
|
+
"version": "8.0.0-beta.0",
|
|
4
4
|
"description": "Test utilities for Yeoman generators",
|
|
5
5
|
"homepage": "http://yeoman.io/authoring/testing.html",
|
|
6
6
|
"author": "The Yeoman Team",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"inquirer": "^9.2.2",
|
|
48
48
|
"lodash": "^4.17.21",
|
|
49
49
|
"mem-fs": "^3.0.0",
|
|
50
|
-
"mem-fs-editor": "^10.0.
|
|
50
|
+
"mem-fs-editor": "^10.0.2",
|
|
51
51
|
"sinon": "^14.0.2",
|
|
52
52
|
"temp-dir": "^3.0.0",
|
|
53
|
-
"yeoman-generator": "^6.0.0-alpha.
|
|
53
|
+
"yeoman-generator": "^6.0.0-alpha.4"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"yeoman-environment": "^3.13.0 || ^4.0.0-alpha.0"
|