test: anchor artifact fixtures before their fixed expiry

This commit is contained in:
Neil
2026-09-05 17:13:04 -07:00
parent 4cc214fef7
commit 263dc98d3b
3 changed files with 23 additions and 3 deletions
@@ -1,7 +1,7 @@
import { mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
vi.mock('electron', () => ({
app: { isPackaged: false },
@@ -21,7 +21,14 @@ const writeRequest = {
authToken: 'token-a'
}
beforeEach(() => {
// Keep fixed response expirations independent of the runner's wall clock.
vi.useFakeTimers({ toFake: ['Date'] })
vi.setSystemTime('2026-08-07T00:00:00.000Z')
})
afterEach(async () => {
vi.useRealTimers()
vi.unstubAllGlobals()
await Promise.all(
createdPaths.splice(0).map((path) => rm(path, { recursive: true, force: true }))
@@ -1,7 +1,7 @@
import { mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
vi.mock('electron', () => ({
app: { isPackaged: false },
@@ -50,7 +50,14 @@ async function setup(): Promise<ArtifactCloudService> {
return new ArtifactCloudService(path, () => true)
}
beforeEach(() => {
// Keep fixed response expirations independent of the runner's wall clock.
vi.useFakeTimers({ toFake: ['Date'] })
vi.setSystemTime('2026-08-07T00:00:00.000Z')
})
afterEach(async () => {
vi.useRealTimers()
vi.unstubAllGlobals()
await Promise.all(
createdPaths.splice(0).map((path) => rm(path, { recursive: true, force: true }))
@@ -1,7 +1,7 @@
import { mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
vi.mock('electron', () => ({
app: { isPackaged: false },
@@ -92,6 +92,12 @@ const writeRequest = {
authToken: 'token-a'
}
beforeEach(() => {
// Keep fixed response expirations independent of the runner's wall clock.
vi.useFakeTimers({ toFake: ['Date'] })
vi.setSystemTime('2026-08-07T00:00:00.000Z')
})
afterEach(async () => {
vi.useRealTimers()
vi.unstubAllGlobals()