I am trying to test my schematic, which requires some initial setup of other schematics (creating a workspace and application) and I want to see only the changes that my schematic makes (not the changes to everything)
Setup:
// Create the workspace
appTree = runner.runExternalSchematic('@schematics/angular', 'workspace', workspaceOptions);
// Create the app
appTree = runner.runExternalSchematic('@schematics/angular', 'application', appOptions, appTree);
// Create a test component
appTree = runner.runExternalSchematic(
'@schematics/angular',
'component',
{name: 'foo', project: appOptions.name} as ComponentOptions,
appTree
);
After some digging, I found tree.actions
allows you to see what has changed on the tree, but it shows all the actions (including the creation of all the Angular stuff)
Test:
it('makes changes', () => {
// Do something to appTree to "commit" changes
const tree = runner.runSchematic('my-schematic', {}, appTree);
// I want `tree.actions` to just show the changes from 'my-schematic'
});
What I want is a way to "commit" the changes to the tree after making all the changes to setup the workspace, app, and component so I can just see the changes and test off of that.
Is there something in the Angular test suite or the general schematics API that would let me do this?