(assert): snapshot testing is hindered by changing hashes
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
Using `ecsPatterns.ApplicationLoadBalancedFargateService` to deploy a Docker asset, every time a single file is changed in the source folder, a new hash and asset is created. This means snapshot testing is not viable, as every minor change leads to a change in snapshot.
### Reproduction Steps
Create a basic `ecsPatterns.ApplicationLoadBalancedFargateService` and add a test file with the contents:
```ts
// stack.test.ts
import { SynthUtils } from "@aws-cdk/assert";
import { App } from "@aws-cdk/core";
import { CDKStack } from "../lib/CDKStack";
const app = new App();
describe("Stack", () => {
const stack = new CDKStack(app, "test");
it("should match snapshot", () => {
expect(SynthUtils.toCloudFormation(stack)).toMatchSnapshot();
});
})
```
Create the snapshot with `yarn test`.
Change a single file in the source folder
Rerun the tests with `yarn test`
### What did you expect to happen?
No change to snapshot
### What actually happened?
Change on snapshot hash

### Environment
- **CDK CLI Version 1.92.0:**
- **Framework Version: 1.92.0**
- **Node.js Version: 14.16.0**
- **OS : MacOS 11.2.2 (Big Sur)**
- **Language (Version): Typescript 4.2.3**
### Other
I expect to find some way of preserving the hash or omitting it from snapshot testing
---
This is :bug: Bug Report
Contributor guide
Research direction
Start with the stack.test.ts reproduction using ecsPatterns.ApplicationLoadBalancedFargateService and SynthUtils.toCloudFormation, then run yarn test before and after changing one source file. Trace where the Docker asset hash enters the synthesized snapshot. Done means a source-file change no longer causes an unwanted snapshot hash change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, typescript
- Domain
- cloud, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100