Bump jest to fix weird prettier bug (#2716)

Our snapshot tests have been acting strange. It turned out that there's
a change in prettier that is incompatible with prettier's inline
snapshots.

This PR:
- updates jest to a compatible alpha
- updates dependencies

### Change Type

- [x] `tests` — Changes to any test code only[^2]

### Test Plan

- [x] Unit Tests
This commit is contained in:
Steve Ruiz 2024-02-04 11:19:47 +00:00 committed by GitHub
parent d3a6d91217
commit dee5d2928c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 526 additions and 532 deletions

View file

@ -155,26 +155,26 @@ describe('AlarmScheduler', () => {
// a...
await advanceTime(1000)
expect(alarms.a).toBeCalledTimes(1)
expect(alarms.b).toBeCalledTimes(0)
expect(alarms.c).toBeCalledTimes(0)
expect(alarms.a).toHaveBeenCalledTimes(1)
expect(alarms.b).toHaveBeenCalledTimes(0)
expect(alarms.c).toHaveBeenCalledTimes(0)
// called for b, then a again to reschedule c:
expect(storage.setAlarm).toHaveBeenCalledTimes(3)
expect(storage.setAlarm).toHaveBeenLastCalledWith(1_001_500)
// ...b...
await advanceTime(500)
expect(alarms.a).toBeCalledTimes(1)
expect(alarms.b).toBeCalledTimes(0)
expect(alarms.c).toBeCalledTimes(1)
expect(alarms.a).toHaveBeenCalledTimes(1)
expect(alarms.b).toHaveBeenCalledTimes(0)
expect(alarms.c).toHaveBeenCalledTimes(1)
expect(storage.setAlarm).toHaveBeenCalledTimes(4)
expect(storage.setAlarm).toHaveBeenLastCalledWith(1_002_000)
// ...c
await advanceTime(500)
expect(alarms.a).toBeCalledTimes(1)
expect(alarms.b).toBeCalledTimes(1)
expect(alarms.c).toBeCalledTimes(1)
expect(alarms.a).toHaveBeenCalledTimes(1)
expect(alarms.b).toHaveBeenCalledTimes(1)
expect(alarms.c).toHaveBeenCalledTimes(1)
expect(storage.setAlarm).toHaveBeenCalledTimes(4)
// sequence should be a -> b -> c:
@ -185,26 +185,26 @@ describe('AlarmScheduler', () => {
// a...
await advanceTime(1000)
expect(alarms.a).toBeCalledTimes(2)
expect(alarms.b).toBeCalledTimes(1)
expect(alarms.c).toBeCalledTimes(1)
expect(alarms.a).toHaveBeenCalledTimes(2)
expect(alarms.b).toHaveBeenCalledTimes(1)
expect(alarms.c).toHaveBeenCalledTimes(1)
// called for b, not needed to reschedule c:
expect(storage.setAlarm).toHaveBeenCalledTimes(6)
expect(storage.setAlarm).toHaveBeenLastCalledWith(1_004_000)
// ...b...
await advanceTime(1000)
expect(alarms.a).toBeCalledTimes(2)
expect(alarms.b).toBeCalledTimes(2)
expect(alarms.c).toBeCalledTimes(1)
expect(alarms.a).toHaveBeenCalledTimes(2)
expect(alarms.b).toHaveBeenCalledTimes(2)
expect(alarms.c).toHaveBeenCalledTimes(1)
expect(storage.setAlarm).toHaveBeenCalledTimes(7)
expect(storage.setAlarm).toHaveBeenLastCalledWith(1_005_000)
// ...c
await advanceTime(1000)
expect(alarms.a).toBeCalledTimes(2)
expect(alarms.b).toBeCalledTimes(2)
expect(alarms.c).toBeCalledTimes(2)
expect(alarms.a).toHaveBeenCalledTimes(2)
expect(alarms.b).toHaveBeenCalledTimes(2)
expect(alarms.c).toHaveBeenCalledTimes(2)
expect(storage.setAlarm).toHaveBeenCalledTimes(7)
})
@ -247,7 +247,7 @@ describe('AlarmScheduler', () => {
})
jest.spyOn(console, 'log').mockImplementation(noop)
await expect(async () => advanceTime(1000)).rejects.toThrowError(
await expect(async () => advanceTime(1000)).rejects.toThrow(
'Some alarms failed to fire, scheduling retry'
)
expect(alarms.error).toHaveBeenCalledTimes(1)

View file

@ -72,9 +72,9 @@
"@microsoft/api-extractor": "^7.35.4",
"@next/eslint-plugin-next": "^13.3.0",
"@swc/core": "^1.3.55",
"@swc/jest": "^0.2.26",
"@swc/jest": "^0.2.34",
"@types/glob": "^8.1.0",
"@types/jest": "^28.1.2",
"@types/jest": "^29.5.12",
"@types/node": "~20.11",
"@types/react": "^18.2.47",
"@types/react-dom": "^18.2.18",
@ -91,7 +91,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"fs-extra": "^11.1.0",
"husky": "^8.0.0",
"jest": "^29.7.0",
"jest": "30.0.0-alpha.2",
"json5": "^2.2.3",
"lazyrepo": "0.0.0-alpha.27",
"lint-staged": ">=10",

View file

@ -29,11 +29,11 @@ describe('get order between', () => {
expect(generateKeyBetween('zzzzzzzzzzzzzzzzzzzzzzzzzzz', undefined)).toBe(
'zzzzzzzzzzzzzzzzzzzzzzzzzzzV'
)
expect(() => generateKeyBetween(undefined, 'A00000000000000000000000000')).toThrowError()
expect(() => generateKeyBetween('a00', undefined)).toThrowError()
expect(() => generateKeyBetween('a00', 'a1')).toThrowError()
expect(() => generateKeyBetween('0', '1')).toThrowError()
expect(() => generateKeyBetween('a1', 'a0')).toThrowError()
expect(() => generateKeyBetween(undefined, 'A00000000000000000000000000')).toThrow()
expect(() => generateKeyBetween('a00', undefined)).toThrow()
expect(() => generateKeyBetween('a00', 'a1')).toThrow()
expect(() => generateKeyBetween('0', '1')).toThrow()
expect(() => generateKeyBetween('a1', 'a0')).toThrow()
})
})

View file

@ -15,7 +15,7 @@ describe('define migrations tests', () => {
// @ts-expect-error first version without current version
firstVersion: Versions.Initial,
})
}).not.toThrowError()
}).not.toThrow()
expect(() => {
// no versions
@ -23,7 +23,7 @@ describe('define migrations tests', () => {
// @ts-expect-error first version without current version
firstVersion: Versions.February,
})
}).not.toThrowError()
}).not.toThrow()
expect(() => {
// empty migrators
@ -31,7 +31,7 @@ describe('define migrations tests', () => {
// @ts-expect-error
migrators: {},
})
}).not.toThrowError()
}).not.toThrow()
expect(() => {
// no versions!
@ -44,7 +44,7 @@ describe('define migrations tests', () => {
},
},
})
}).not.toThrowError()
}).not.toThrow()
expect(() => {
// wrong current version!
@ -58,7 +58,7 @@ describe('define migrations tests', () => {
},
},
})
}).not.toThrowError()
}).not.toThrow()
expect(() => {
defineMigrations({
@ -76,7 +76,7 @@ describe('define migrations tests', () => {
},
},
})
}).not.toThrowError()
}).not.toThrow()
expect(() => {
// can't provide only first version
@ -86,7 +86,7 @@ describe('define migrations tests', () => {
// @ts-expect-error migrators without current version
migrators: {},
})
}).not.toThrowError()
}).not.toThrow()
expect(() => {
// same version
@ -95,7 +95,7 @@ describe('define migrations tests', () => {
currentVersion: Versions.Initial,
migrators: {},
})
}).toThrowError()
}).toThrow()
expect(() => {
// only first version
@ -105,7 +105,7 @@ describe('define migrations tests', () => {
// @ts-expect-error
migrators: {},
})
}).not.toThrowError()
}).not.toThrow()
expect(() => {
// missing only version
@ -115,7 +115,7 @@ describe('define migrations tests', () => {
// @ts-expect-error
migrators: {},
})
}).toThrowError()
}).toThrow()
expect(() => {
// only version, explicit start and current
@ -129,7 +129,7 @@ describe('define migrations tests', () => {
},
},
})
}).toThrowError()
}).toThrow()
expect(() => {
// missing later versions
@ -139,7 +139,7 @@ describe('define migrations tests', () => {
// @ts-expect-error
migrators: {},
})
}).not.toThrowError()
}).not.toThrow()
expect(() => {
// missing later versions
@ -154,7 +154,7 @@ describe('define migrations tests', () => {
},
},
})
}).not.toThrowError()
}).not.toThrow()
expect(() => {
// missing earlier versions
@ -169,7 +169,7 @@ describe('define migrations tests', () => {
},
},
})
}).not.toThrowError()
}).not.toThrow()
expect(() => {
// got em all
@ -187,7 +187,7 @@ describe('define migrations tests', () => {
},
},
})
}).not.toThrowError()
}).not.toThrow()
expect(() => {
// got em all starting later
@ -205,7 +205,7 @@ describe('define migrations tests', () => {
},
},
})
}).not.toThrowError()
}).not.toThrow()
expect(() => {
// first migration should be first version + 1
@ -224,6 +224,6 @@ describe('define migrations tests', () => {
},
},
})
}).not.toThrowError()
}).not.toThrow()
})
})

View file

@ -912,6 +912,6 @@ describe('snapshots', () => {
expect(() => {
store2.loadSnapshot(snapshot1)
}).not.toThrowError()
}).not.toThrow()
})
})

View file

@ -112,14 +112,14 @@ describe('Validating initial data', () => {
it('Validates initial data', () => {
expect(() => {
new Store<Book | Author>({ schema, initialData: snapshot, props: {} })
}).not.toThrowError()
}).not.toThrow()
expect(() => {
// @ts-expect-error
snapshot[0].name = 4
new Store<Book | Author>({ schema, initialData: snapshot, props: {} })
}).toThrowError()
}).toThrow()
})
})

View file

@ -79,7 +79,7 @@ it('Uses typescript generics', () => {
type: 'arrow',
},
])
}).toThrowError()
}).toThrow()
})
it('Parents shapes to the current page if the parent is not found', () => {

View file

@ -16,17 +16,17 @@ describe('Migrations', () => {
const withoutSchema = structuredClone(clipboardContent)
// @ts-expect-error
delete withoutSchema.schema
expect(() => editor.putContentOntoCurrentPage(withoutSchema)).toThrowError()
expect(() => editor.putContentOntoCurrentPage(withoutSchema)).toThrow()
})
it('Does not throw error if content has a schema', () => {
expect(() => editor.putContentOntoCurrentPage(clipboardContent)).not.toThrowError()
expect(() => editor.putContentOntoCurrentPage(clipboardContent)).not.toThrow()
})
it('Throws error if any shape is invalid due to wrong type', () => {
const withInvalidShapeType = structuredClone(clipboardContent)
withInvalidShapeType.shapes[0].type = 'invalid'
expect(() => editor.putContentOntoCurrentPage(withInvalidShapeType)).toThrowError()
expect(() => editor.putContentOntoCurrentPage(withInvalidShapeType)).toThrow()
})
// we temporarily disabled validations
@ -34,6 +34,6 @@ describe('Migrations', () => {
const withInvalidShapeModel = structuredClone(clipboardContent)
// @ts-expect-error
withInvalidShapeModel.shapes[0].x = 'invalid'
expect(() => editor.putContentOntoCurrentPage(withInvalidShapeModel)).toThrowError()
expect(() => editor.putContentOntoCurrentPage(withInvalidShapeModel)).toThrow()
})
})

View file

@ -77,7 +77,7 @@ it('Uses typescript generics', () => {
type: 'arrow',
},
])
}).toThrowError()
}).toThrow()
})
it('updates shapes', () => {

View file

@ -1,6 +1,7 @@
import { debounce } from './debounce'
jest.useFakeTimers()
describe(debounce, () => {
it('should debounce a function', async () => {
const fn = jest.fn()
@ -8,13 +9,13 @@ describe(debounce, () => {
debounced()
debounced()
debounced()
expect(fn).not.toBeCalled()
expect(fn).not.toHaveBeenCalled()
jest.advanceTimersByTime(200)
expect(fn).toBeCalledTimes(1)
expect(fn).toHaveBeenCalledTimes(1)
jest.advanceTimersByTime(200)
expect(fn).toBeCalledTimes(1)
expect(fn).toHaveBeenCalledTimes(1)
jest.advanceTimersByTime(200)
expect(fn).toBeCalledTimes(1)
expect(fn).toHaveBeenCalledTimes(1)
})
it('should debounce a function with arguments', async () => {
@ -23,10 +24,10 @@ describe(debounce, () => {
debounced('a', 'b')
debounced('a', 'b')
debounced('a', 'b')
expect(fn).not.toBeCalled()
expect(fn).not.toHaveBeenCalled()
jest.advanceTimersByTime(200)
expect(fn).toBeCalledTimes(1)
expect(fn).toBeCalledWith('a', 'b')
expect(fn).toHaveBeenCalledTimes(1)
expect(fn).toHaveBeenCalledWith('a', 'b')
})
it('should debounce a function with arguments and return a promise', async () => {
@ -35,9 +36,9 @@ describe(debounce, () => {
const promiseA = debounced('a', 'b')
const promiseB = debounced('c', 'd')
const promiseC = debounced('e', 'f')
expect(fn).not.toBeCalled()
expect(fn).not.toHaveBeenCalled()
jest.advanceTimersByTime(200)
expect(fn).toBeCalledTimes(1)
expect(fn).toHaveBeenCalledTimes(1)
const results = await Promise.all([promiseA, promiseB, promiseC])
expect(results).toEqual(['ef', 'ef', 'ef'])
@ -48,19 +49,19 @@ describe(debounce, () => {
const debounced = debounce(fn, 100)
const promiseA = debounced('a', 'b')
const promiseB = debounced('c', 'd')
expect(fn).not.toBeCalled()
expect(fn).not.toHaveBeenCalled()
jest.advanceTimersByTime(200)
expect(fn).toBeCalledTimes(1)
expect(fn).toHaveBeenCalledTimes(1)
expect(await Promise.all([promiseA, promiseB])).toEqual(['cd', 'cd'])
const promiseC = debounced('e', 'f')
const promiseD = debounced('g', 'h')
expect(fn).toBeCalledTimes(1)
expect(fn).toHaveBeenCalledTimes(1)
jest.advanceTimersByTime(200)
expect(fn).toBeCalledTimes(2)
expect(fn).toHaveBeenCalledTimes(2)
expect(await Promise.all([promiseC, promiseD])).toEqual(['gh', 'gh'])
})
})

925
yarn.lock

File diff suppressed because it is too large Load diff