Skip to content

Commit

Permalink
feat(awscdk): task to update snapshot of all integrations tests (proj…
Browse files Browse the repository at this point in the history
…en#1543)

The task is named `integ:snapshot-all` and can be used together with the
feat added in projen#1476.

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • Loading branch information
jogold authored Jan 19, 2022
1 parent bb9231e commit 15ee147
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/awscdk/integration-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ export class IntegrationTest extends Component {
exec: `cdk synth ${cdkopts} -o ${snapshotdir} > /dev/null`,
});

let snapshotAllTask = project.tasks.tryFind("integ:snapshot-all");
if (!snapshotAllTask) {
snapshotAllTask = project.addTask("integ:snapshot-all", {
description: "update snapshot for all integration tests",
});
}
snapshotAllTask.spawn(snapshotTask);

// synth as part of our tests, which means that if outdir changes, anti-tamper will fail
project.testTask.spawn(assertTask);
project.addGitIgnore(`!${snapshotdir}`); // commit outdir to git but not assets
Expand Down
15 changes: 15 additions & 0 deletions test/awscdk/__snapshots__/integration-test.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions test/awscdk/integration-test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ describe("IntegrationTest", () => {
cdkDeps: project.cdkDeps,
});

new awscdk.IntegrationTest(project, {
entrypoint: "test/bar.integ.ts",
tsconfigPath: project.tsconfigDev.fileName,
cdkDeps: project.cdkDeps,
});

// THEN
const output = Testing.synth(project);

Expand Down Expand Up @@ -59,6 +65,7 @@ describe("IntegrationTest", () => {
"integ:foo:destroy",
"integ:foo:snapshot",
"integ:foo:watch",
"integ:snapshot-all",
];

const actualTaskNames = Object.keys(output[".projen/tasks.json"].tasks);
Expand Down

0 comments on commit 15ee147

Please sign in to comment.