Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
* Unit tests for the action's entrypoint, src/index.ts
*/

import * as main from '../src/main'
import { jest, describe, it, expect } from '@jest/globals'

// Mock the action's entrypoint
const runMock = jest.spyOn(main, 'run').mockImplementation()
const runMock = jest.fn<() => Promise<void>>()

jest.unstable_mockModule('../src/main', () => ({
run: runMock
}))

describe('index', () => {
it('calls run when imported', async () => {
// eslint-disable-next-line @typescript-eslint/no-require-imports
require('../src/index')
await import('../src/index')

expect(runMock).toHaveBeenCalled()
})
Expand Down
75 changes: 56 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
"format:check": "prettier --check **/*.ts",
"lint": "npx eslint",
"package": "ncc build src/index.ts",
"test": "jest"
"test": "NODE_OPTIONS='--experimental-vm-modules' jest"
},
"jest": {
"preset": "ts-jest",
"verbose": true,
"clearMocks": true,
"testEnvironment": "node",
"extensionsToTreatAsEsm": [".ts"],
"moduleFileExtensions": [
"js",
"ts"
Expand All @@ -45,13 +45,13 @@
"/dist/"
],
"transform": {
"^.+\\.ts$": "ts-jest"
"^.+\\.ts$": ["ts-jest", { "useESM": true }]
}
},
"dependencies": {
"@actions/core": "^2.0.1",
"@actions/github": "^6.0.1",
"@actions/tool-cache": "^3.0.0",
"@actions/tool-cache": "^4.0.0",
"semver": "^7.7.4"
},
"devDependencies": {
Expand Down