Skip to content

Commit

Permalink
Support env.UPDATE_SNAPSHOTS=1 (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
hasparus authored Nov 18, 2021
1 parent f06b941 commit d02b7d6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wet-buttons-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'earljs': patch
---

process.env.UPDATE_SNAPSHOTS set to "1" is now treated the same as when set to "true"
2 changes: 1 addition & 1 deletion packages/earljs/src/validators/snapshots/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type Env = typeof process.env

export type ShouldUpdateSnapshots = () => boolean
export function shouldUpdateSnapshots(env: Env): boolean {
return env.UPDATE_SNAPSHOTS === 'true'
return env.UPDATE_SNAPSHOTS === 'true' || env.UPDATE_SNAPSHOTS === '1'
}

const SNAPSHOTS_DIR = '__snapshots__'
Expand Down
1 change: 1 addition & 0 deletions packages/earljs/test/validators/snapshots/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('getUpdateSnapshotMode', () => {

it('should update all snapshots when requested', () => {
expect(getUpdateSnapshotMode({ UPDATE_SNAPSHOTS: 'true' })).to.eq('all')
expect(getUpdateSnapshotMode({ UPDATE_SNAPSHOTS: '1' })).to.eq('all')
})

it('should update only new snapshots by default', () => {
Expand Down

0 comments on commit d02b7d6

Please sign in to comment.