Skip to content

(assert): Snapshot testing not working with 1.101.0 - directory references causes tests to diff #14468

@markusl

Description

@markusl

We utilize snapshots for a large amount of regression testing like this:

  const app = new cdk.App({
    context: {
      '@aws-cdk/core:newStyleStackSynthesis': 'true',
    },
    outdir: './cdk.out',
    stackTraces: false,
  });
  // WHEN
  const stack = createStack(...);

  // THEN
  expect(SynthUtils.toCloudFormation(stack)).toMatchSnapshot();

Reproduction Steps

See previous code.

What did you expect to happen?

Should so that regression testing using snapshots is possible.

What actually happened?

It seems that 1.101.0 has changed somehow and generates a new directory reference with every build which causes diffs:

    - Snapshot  - 2
    + Received  + 2
    @@ -249,11 +249,11 @@
                "libraries": Object {},
              },
              "version": "9.0.0",
            },
            "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
    -       "file": "/Users/user/repo/cdk.out/Stack.assets.json",
    +       "file": "/codebuild/output/src976733808/src/git-codecommit.eu-central-1.amazonaws.com/v1/repos/repo/cdk.out/Stack.assets.json",
            "id": "Stack.assets",
            "manifest": Object {
              "properties": Object {
                "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
                "file": "Stack.assets.json",
    @@ -270,11 +270,11 @@
            AssetManifestArtifact {
              "_dependencyIDs": Array [],
              "_deps": Array [],
              "assembly": [Circular],
              "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
    -         "file": "/Users/user/repo/cdk.out/Stack.assets.json",
    +         "file": "/codebuild/output/src976733808/src/git-codecommit.eu-central-1.amazonaws.com/v1/repos/repo/cdk.out/Stack.assets.json",
              "id": "Stack.assets",
              "manifest": Object {
                "properties": Object {
                  "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
                  "file": "Stack.assets.json",

      63 | 
 
--

Environment

  • CDK CLI Version :
  • Framework Version: 1.101.0
  • Node.js Version:
  • OS : macOS
  • Language (Version): TypeScript 4

Other


This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

@aws-cdk/assertRelated to the @aws-cdk/assert packagebugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.response-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions