Compare commits

...

2 Commits

Author SHA1 Message Date
Daniel Kennedy f94d96c596 test: fix deprecated Jest matchers for v30
- Replace toThrowError() with toThrow()
- Replace toBeCalledWith() with toHaveBeenCalledWith()
- Update snapshots
2026-01-30 09:44:37 -05:00
Daniel Kennedy 59d7acc324 chore: bump Jest to v30
- jest: ^29.7.0 → ^30.0.0
- @types/jest: ^29.5.12 → ^30.0.0
- ts-jest: ^29.1.1 → ^29.4.6
2026-01-30 09:44:29 -05:00
16 changed files with 1228 additions and 703 deletions
+1179 -654
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "root",
"private": true,
"private": true,
"scripts": {
"audit-all": "lerna run audit-moderate",
"bootstrap": "lerna exec -- npm install",
@@ -16,7 +16,7 @@
"test": "jest --testTimeout 70000"
},
"devDependencies": {
"@types/jest": "^29.5.4",
"@types/jest": "^30.0.0",
"@types/node": "^24.1.0",
"@types/signale": "^1.4.1",
"concurrently": "^6.1.0",
@@ -26,11 +26,11 @@
"eslint-plugin-jest": "^27.2.3",
"eslint-plugin-prettier": "^5.0.0",
"flow-bin": "^0.115.0",
"jest": "^29.6.4",
"jest": "^30.2.0",
"lerna": "^6.4.1",
"nx": "16.6.0",
"prettier": "^3.0.0",
"ts-jest": "^29.1.1",
"ts-jest": "^29.4.6",
"typescript": "^5.2.2"
},
"overrides": {
@@ -47,4 +47,4 @@
"uri-js": "npm:uri-js-replace@^1.0.1",
"node-fetch": "^3.3.2"
}
}
}
@@ -192,7 +192,7 @@ describe('artifact-http-client', () => {
name: 'artifact',
version: 4
})
}).rejects.toThrowError(
}).rejects.toThrow(
'Failed to make request after 5 attempts: Failed request: (500) Internal Server Error'
)
expect(mockHttpClient).toHaveBeenCalledTimes(1)
@@ -227,7 +227,7 @@ describe('artifact-http-client', () => {
name: 'artifact',
version: 4
})
}).rejects.toThrowError(
}).rejects.toThrow(
'Received non-retryable error: Failed request: (401) Unauthorized'
)
expect(mockHttpClient).toHaveBeenCalledTimes(1)
@@ -271,7 +271,7 @@ describe('artifact-http-client', () => {
name: 'artifact',
version: 4
})
}).rejects.toThrowError(
}).rejects.toThrow(
'Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run'
)
expect(mockHttpClient).toHaveBeenCalledTimes(1)
@@ -306,7 +306,7 @@ describe('artifact-http-client', () => {
name: 'artifact',
version: 4
})
}).rejects.toThrowError(new NetworkError('ENOTFOUND').message)
}).rejects.toThrow(new NetworkError('ENOTFOUND').message)
expect(mockHttpClient).toHaveBeenCalledTimes(1)
expect(mockPost).toHaveBeenCalledTimes(1)
})
@@ -341,7 +341,7 @@ describe('artifact-http-client', () => {
name: 'artifact',
version: 4
})
}).rejects.toThrowError(new UsageError().message)
}).rejects.toThrow(new UsageError().message)
expect(mockHttpClient).toHaveBeenCalledTimes(1)
expect(mockPost).toHaveBeenCalledTimes(1)
})
@@ -134,7 +134,7 @@ describe('get-artifact', () => {
fixtures.token
)
expect(response).rejects.toThrowError(ArtifactNotFoundError)
expect(response).rejects.toThrow(ArtifactNotFoundError)
})
it('should fail if non-200 response', async () => {
@@ -155,7 +155,7 @@ describe('get-artifact', () => {
fixtures.token
)
expect(response).rejects.toThrowError(InvalidResponseError)
expect(response).rejects.toThrow(InvalidResponseError)
})
})
@@ -223,7 +223,7 @@ describe('get-artifact', () => {
const response = getArtifactInternal(fixtures.artifacts[0].name)
expect(response).rejects.toThrowError(ArtifactNotFoundError)
expect(response).rejects.toThrow(ArtifactNotFoundError)
})
it('should fail if non-200 response', async () => {
@@ -132,7 +132,7 @@ describe('upload-artifact', () => {
fixtures.inputs.files,
fixtures.inputs.rootDirectory
)
await expect(uploadResp).rejects.toThrowError(FilesNotFoundError)
await expect(uploadResp).rejects.toThrow(FilesNotFoundError)
})
it('should reject if no backend IDs are found', async () => {
+4 -4
View File
@@ -26,7 +26,7 @@ describe('get-backend-ids-from-token', () => {
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwic2NwIjoiQWN0aW9ucy5FeGFtcGxlIEFjdGlvbnMuQW5vdGhlckV4YW1wbGU6dGVzdCIsImlhdCI6MTUxNjIzOTAyMn0.K0IEoULZteGevF38G94xiaA8zcZ5UlKWfGfqE6q3dhw'
)
expect(util.getBackendIdsFromToken).toThrowError(
expect(util.getBackendIdsFromToken).toThrow(
'Failed to get backend IDs: The provided JWT token is invalid'
)
})
@@ -38,7 +38,7 @@ describe('get-backend-ids-from-token', () => {
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwic2NwIjoiQWN0aW9ucy5FeGFtcGxlIEFjdGlvbnMuQW5vdGhlckV4YW1wbGU6dGVzdCBBY3Rpb25zLlJlc3VsdHM6Y2U3ZjU0YzctNjFjNy00YWFlLTg4N2YtMzBkYTQ3NWY1ZjFhIiwiaWF0IjoxNTE2MjM5MDIyfQ.7D0_LRfRFRZFImHQ7GxH2S6ZyFjjZ5U0ujjGCfle1XE'
)
expect(util.getBackendIdsFromToken).toThrowError(
expect(util.getBackendIdsFromToken).toThrow(
'Failed to get backend IDs: The provided JWT token is invalid'
)
})
@@ -46,7 +46,7 @@ describe('get-backend-ids-from-token', () => {
it('should throw an error when the token is in an invalid format', () => {
jest.spyOn(config, 'getRuntimeToken').mockReturnValue('token')
expect(util.getBackendIdsFromToken).toThrowError('Invalid token specified')
expect(util.getBackendIdsFromToken).toThrow('Invalid token specified')
})
it("should throw an error when the token doesn't have the right field", () => {
@@ -56,7 +56,7 @@ describe('get-backend-ids-from-token', () => {
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
)
expect(util.getBackendIdsFromToken).toThrowError(
expect(util.getBackendIdsFromToken).toThrow(
'Failed to get backend IDs: The provided JWT token is invalid'
)
})
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`buildIntotoStatement returns an intoto statement 1`] = `
{
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`provenance functions buildSLSAProvenancePredicate returns a provenance hydrated from an OIDC token 1`] = `
{
+1 -1
View File
@@ -8,7 +8,7 @@ describe('attest', () => {
predicate: {bar: 'baz'},
token: 'token'
}
expect(attest(options)).rejects.toThrowError(
expect(attest(options)).rejects.toThrow(
'Must provide either subjectName and subjectDigest or subjects'
)
})
+1 -1
View File
@@ -30,7 +30,7 @@ test('unlinkFile unlinks file', async () => {
})
test('assertDefined throws if undefined', () => {
expect(() => cacheUtils.assertDefined('test', undefined)).toThrowError()
expect(() => cacheUtils.assertDefined('test', undefined)).toThrow()
})
test('assertDefined returns value', () => {
+4 -4
View File
@@ -29,7 +29,7 @@ beforeAll(() => {
test('restore with no path should fail', async () => {
const paths: string[] = []
const key = 'node-test'
await expect(restoreCache(paths, key)).rejects.toThrowError(
await expect(restoreCache(paths, key)).rejects.toThrow(
`Path Validation Error: At least one directory or file path is required`
)
})
@@ -38,7 +38,7 @@ test('restore with too many keys should fail', async () => {
const paths = ['node_modules']
const key = 'node-test'
const restoreKeys = [...Array(20).keys()].map(x => x.toString())
await expect(restoreCache(paths, key, restoreKeys)).rejects.toThrowError(
await expect(restoreCache(paths, key, restoreKeys)).rejects.toThrow(
`Key Validation Error: Keys are limited to a maximum of 10.`
)
})
@@ -46,7 +46,7 @@ test('restore with too many keys should fail', async () => {
test('restore with large key should fail', async () => {
const paths = ['node_modules']
const key = 'foo'.repeat(512) // Over the 512 character limit
await expect(restoreCache(paths, key)).rejects.toThrowError(
await expect(restoreCache(paths, key)).rejects.toThrow(
`Key Validation Error: ${key} cannot be larger than 512 characters.`
)
})
@@ -54,7 +54,7 @@ test('restore with large key should fail', async () => {
test('restore with invalid key should fail', async () => {
const paths = ['node_modules']
const key = 'comma,comma'
await expect(restoreCache(paths, key)).rejects.toThrowError(
await expect(restoreCache(paths, key)).rejects.toThrow(
`Key Validation Error: ${key} cannot contain commas.`
)
})
+4 -4
View File
@@ -44,7 +44,7 @@ afterEach(() => {
test('restore with no path should fail', async () => {
const paths: string[] = []
const key = 'node-test'
await expect(restoreCache(paths, key)).rejects.toThrowError(
await expect(restoreCache(paths, key)).rejects.toThrow(
`Path Validation Error: At least one directory or file path is required`
)
})
@@ -53,7 +53,7 @@ test('restore with too many keys should fail', async () => {
const paths = ['node_modules']
const key = 'node-test'
const restoreKeys = [...Array(20).keys()].map(x => x.toString())
await expect(restoreCache(paths, key, restoreKeys)).rejects.toThrowError(
await expect(restoreCache(paths, key, restoreKeys)).rejects.toThrow(
`Key Validation Error: Keys are limited to a maximum of 10.`
)
})
@@ -61,7 +61,7 @@ test('restore with too many keys should fail', async () => {
test('restore with large key should fail', async () => {
const paths = ['node_modules']
const key = 'foo'.repeat(512) // Over the 512 character limit
await expect(restoreCache(paths, key)).rejects.toThrowError(
await expect(restoreCache(paths, key)).rejects.toThrow(
`Key Validation Error: ${key} cannot be larger than 512 characters.`
)
})
@@ -69,7 +69,7 @@ test('restore with large key should fail', async () => {
test('restore with invalid key should fail', async () => {
const paths = ['node_modules']
const key = 'comma,comma'
await expect(restoreCache(paths, key)).rejects.toThrowError(
await expect(restoreCache(paths, key)).rejects.toThrow(
`Key Validation Error: ${key} cannot contain commas.`
)
})
+2 -2
View File
@@ -40,7 +40,7 @@ beforeAll(() => {
test('save with missing input should fail', async () => {
const paths: string[] = []
const primaryKey = 'Linux-node-bb828da54c148048dd17899ba9fda624811cfb43'
await expect(saveCache(paths, primaryKey)).rejects.toThrowError(
await expect(saveCache(paths, primaryKey)).rejects.toThrow(
`Path Validation Error: At least one directory or file path is required`
)
})
@@ -342,7 +342,7 @@ test('save with non existing path should not save cache', async () => {
jest.spyOn(cacheUtils, 'resolvePaths').mockImplementation(async () => {
return []
})
await expect(saveCache([path], primaryKey)).rejects.toThrowError(
await expect(saveCache([path], primaryKey)).rejects.toThrow(
`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`
)
})
+2 -2
View File
@@ -54,7 +54,7 @@ test('save with missing input should fail', async () => {
const paths: string[] = []
const key = 'Linux-node-bb828da54c148048dd17899ba9fda624811cfb43'
await expect(saveCache(paths, key)).rejects.toThrowError(
await expect(saveCache(paths, key)).rejects.toThrow(
`Path Validation Error: At least one directory or file path is required`
)
})
@@ -581,7 +581,7 @@ test('save with non existing path should not save cache using v2 saveCache', asy
jest.spyOn(cacheUtils, 'resolvePaths').mockImplementation(async () => {
return []
})
await expect(saveCache([path], key)).rejects.toThrowError(
await expect(saveCache([path], key)).rejects.toThrow(
`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`
)
})
+14 -14
View File
@@ -55,12 +55,12 @@ describe('@actions/exec', () => {
expect(exitCode).toBe(0)
if (IS_WINDOWS) {
expect(outstream.write).toBeCalledWith(
expect(outstream.write).toHaveBeenCalledWith(
`[command]${toolpath} /c echo hello${os.EOL}`
)
expect(outstream.write).toBeCalledWith(Buffer.from(`hello${os.EOL}`))
expect(outstream.write).toHaveBeenCalledWith(Buffer.from(`hello${os.EOL}`))
} else {
expect(outstream.write).toBeCalledWith(
expect(outstream.write).toHaveBeenCalledWith(
`[command]${toolpath} -l -a${os.EOL}`
)
}
@@ -85,12 +85,12 @@ describe('@actions/exec', () => {
expect(exitCode).toBe(0)
if (IS_WINDOWS) {
expect(outstream.write).toBeCalledWith(
expect(outstream.write).toHaveBeenCalledWith(
`[command]${toolpath} /c echo hello${os.EOL}`
)
expect(outstream.write).toBeCalledWith(Buffer.from(`hello${os.EOL}`))
expect(outstream.write).toHaveBeenCalledWith(Buffer.from(`hello${os.EOL}`))
} else {
expect(outstream.write).toBeCalledWith(
expect(outstream.write).toHaveBeenCalledWith(
`[command]${toolpath} -l -a${os.EOL}`
)
}
@@ -115,12 +115,12 @@ describe('@actions/exec', () => {
expect(exitCode).toBe(0)
if (IS_WINDOWS) {
expect(outstream.write).toBeCalledWith(
expect(outstream.write).toHaveBeenCalledWith(
`[command]${toolpath} /c echo hello${os.EOL}`
)
expect(outstream.write).toBeCalledWith(Buffer.from(`hello${os.EOL}`))
expect(outstream.write).toHaveBeenCalledWith(Buffer.from(`hello${os.EOL}`))
} else {
expect(outstream.write).toBeCalledWith(
expect(outstream.write).toHaveBeenCalledWith(
`[command]${toolpath} -l -a${os.EOL}`
)
}
@@ -182,11 +182,11 @@ describe('@actions/exec', () => {
expect(failed).toBe(true)
if (IS_WINDOWS) {
expect(outstream.write).toBeCalledWith(
expect(outstream.write).toHaveBeenCalledWith(
`[command]${toolpath} /c non-existent${os.EOL}`
)
} else {
expect(outstream.write).toBeCalledWith(
expect(outstream.write).toHaveBeenCalledWith(
`[command]${toolpath} -l non-existent${os.EOL}`
)
}
@@ -209,7 +209,7 @@ describe('@actions/exec', () => {
)
expect(exitCode).toBe(0)
expect(outstream.write).toBeCalledWith(
expect(outstream.write).toHaveBeenCalledWith(
Buffer.from('this is output to stderr')
)
})
@@ -233,7 +233,7 @@ describe('@actions/exec', () => {
})
expect(failed).toBe(true)
expect(errstream.write).toBeCalledWith(
expect(errstream.write).toHaveBeenCalledWith(
Buffer.from('this is output to stderr')
)
})
@@ -524,7 +524,7 @@ describe('@actions/exec', () => {
const execOptions = getExecOptions()
execOptions.cwd = 'nonexistent/path'
await expect(exec.exec('ls', ['-all'], execOptions)).rejects.toThrowError(
await expect(exec.exec('ls', ['-all'], execOptions)).rejects.toThrow(
`The cwd: ${execOptions.cwd} does not exist!`
)
})
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`@actions/context return error for context.repo when repository doesn't exist 1`] = `"context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'"`;