我创建了一个易于测试的原理图,因为 Angular CLI 是基于原理图的。要创建我可以检查的文件树,我所要做的就是设置appTree
如下:
const schematicRunner = new SchematicTestRunner(
'schematics',
path.join(__dirname, './../collection.json'),
);
let appTree: UnitTestTree;
// tslint:disable-next-line:no-any
const workspaceOptions: any = {
name: 'workspace',
newProjectRoot: 'projects',
version: '0.5.0',
};
// tslint:disable-next-line:no-any
const appOptions: any = {
name: 'authtest',
inlineStyle: false,
inlineTemplate: false,
routing: false,
style: 'css',
skipTests: false,
};
beforeEach(() => {
appTree = schematicRunner.runExternalSchematic('@schematics/angular', 'workspace', workspaceOptions);
appTree = schematicRunner.runExternalSchematic('@schematics/angular', 'application', appOptions, appTree);
});
在 React 或 Vue 项目(分别使用 Create React App 和 Vue CLI 生成)上测试我的应用程序时,是否可以创建类似的文件树?
如果没有,有没有办法将package.json
文件加载到树中?这是我要加载的主文件,以便查找依赖项并从我的 Schematic 中选择 Angular、React 或 Vue 模板。