Skip to content

Commit

Permalink
Only update snapshots in non-production mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
iclanton committed Jul 15, 2020
1 parent 64ee507 commit 7df2917
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion apps/heft/src/cli/actions/TestAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class TestHooks extends ActionHooksBase<ITestActionProperties> {
*/
export interface ITestActionProperties {
watchMode: boolean;
productionFlag: boolean;
}

/**
Expand Down Expand Up @@ -60,7 +61,8 @@ export class TestAction extends BuildAction {
const testActionContext: ITestActionContext = {
hooks: new TestHooks(),
properties: {
watchMode: buildActionContext.properties.watchMode
watchMode: buildActionContext.properties.watchMode,
productionFlag: buildActionContext.properties.productionFlag
}
};
const shouldBuild: boolean = !this._noBuildFlag.value;
Expand Down
13 changes: 11 additions & 2 deletions apps/heft/src/plugins/JestPlugin/JestPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ export class JestPlugin implements IHeftPlugin {
if (FileSystem.exists(path.join(heftConfiguration.buildFolder, JEST_CONFIGURATION_LOCATION))) {
heftSession.hooks.test.tap(PLUGIN_NAME, (test: ITestActionContext) => {
test.hooks.run.tapPromise(PLUGIN_NAME, async () => {
await this._runJestAsync(heftConfiguration, test.properties.watchMode);
await this._runJestAsync(
heftConfiguration,
test.properties.watchMode,
test.properties.productionFlag
);
});
});
}
}

private async _runJestAsync(heftConfiguration: HeftConfiguration, watchMode: boolean): Promise<void> {
private async _runJestAsync(
heftConfiguration: HeftConfiguration,
watchMode: boolean,
production: boolean
): Promise<void> {
const buildFolder: string = heftConfiguration.buildFolder;
const reporterOptions: IHeftJestReporterOptions = { heftConfiguration };
const { results: jestResults } = await runCLI(
Expand All @@ -36,6 +44,7 @@ export class JestPlugin implements IHeftPlugin {
config: JEST_CONFIGURATION_LOCATION,
reporters: [[path.resolve(__dirname, 'HeftJestReporter.js'), reporterOptions]],
cacheDirectory: path.join(heftConfiguration.buildCacheFolder, 'jest-cache'),
updateSnapshot: !production,

listTests: false,
rootDir: buildFolder,
Expand Down
2 changes: 2 additions & 0 deletions common/reviews/api/heft.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ export interface ITestActionContext extends IActionContext<TestHooks, ITestActio

// @public (undocumented)
export interface ITestActionProperties {
// (undocumented)
productionFlag: boolean;
// (undocumented)
watchMode: boolean;
}
Expand Down

0 comments on commit 7df2917

Please sign in to comment.