diff --git a/src/index.ts b/src/index.ts index e49be7d..2f0c747 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import * as core from '@actions/core' -import type SemanticRelease from 'semantic-release' +import type * as SemanticRelease from 'semantic-release' import defaultConfig from './defaultConfig' import { install } from './util/install' import { forceRelease, initialRelease } from './plugin' diff --git a/src/plugin/forceRelease.ts b/src/plugin/forceRelease.ts index e295e63..55ce5f8 100644 --- a/src/plugin/forceRelease.ts +++ b/src/plugin/forceRelease.ts @@ -1,4 +1,4 @@ -import type SemanticRelease from 'semantic-release' +import type * as SemanticRelease from 'semantic-release' import type { PluginConfig } from '../semantic-release' import { getReleaseType, releaseTypes } from './shared/releaseTypes' diff --git a/src/plugin/initialRelease.ts b/src/plugin/initialRelease.ts index 3e8005a..d32c524 100644 --- a/src/plugin/initialRelease.ts +++ b/src/plugin/initialRelease.ts @@ -1,4 +1,4 @@ -import type SemanticRelease from 'semantic-release' +import type * as SemanticRelease from 'semantic-release' import type { PluginConfig } from '../semantic-release' import { releaseTypes } from './shared/releaseTypes' diff --git a/src/semantic-release.d.ts b/src/semantic-release.d.ts index eebbf55..5693fc1 100644 --- a/src/semantic-release.d.ts +++ b/src/semantic-release.d.ts @@ -1,4 +1,4 @@ -import SemanticRelease from 'semantic-release' +import type * as SemanticRelease from 'semantic-release' export type PluginConfig = { [k: string]: unknown, diff --git a/test/_releaseResult.ts b/test/_releaseResult.ts index 0cd7fdc..97b7062 100644 --- a/test/_releaseResult.ts +++ b/test/_releaseResult.ts @@ -1,4 +1,4 @@ -import SemanticRelease from 'semantic-release' +import * as SemanticRelease from 'semantic-release' // see https://github.com/semantic-release/semantic-release/blob/master/docs/developer-guide/js-api.md export default { diff --git a/test/action.ts b/test/action.ts index eeff003..e5653b5 100644 --- a/test/action.ts +++ b/test/action.ts @@ -10,6 +10,6 @@ it('import with side-effect', async () => { run = jest.fn(() => Promise.resolve()) return import('../src/action').then(() => { - expect(run).toBeCalled() + expect(run).toHaveBeenCalled() }) }) diff --git a/test/index.ts b/test/index.ts index 8a652e3..74c5875 100644 --- a/test/index.ts +++ b/test/index.ts @@ -1,4 +1,4 @@ -import type SemanticRelease from 'semantic-release' +import type * as SemanticRelease from 'semantic-release' import run from '../src/index' import { forceRelease, initialRelease } from '../src/plugin' import defaultResult from './_releaseResult' @@ -92,7 +92,7 @@ it('run with dry run option', () => { return run.finally(() => { expect(coreDebug).toEqual(expect.arrayContaining(['DRY RUN'])) - expect(release).toBeCalledTimes(1) + expect(release).toHaveBeenCalledTimes(1) expect(release.mock.calls[0][0]).toMatchObject({dryRun: true}) }) }) @@ -103,8 +103,8 @@ it('run with debug option', () => { const run = exec({debug: 'true'}) return run.finally(() => { - expect(debugEnable).toBeCalled() - expect(release).toBeCalled() + expect(debugEnable).toHaveBeenCalled() + expect(release).toHaveBeenCalled() }) }) @@ -135,7 +135,7 @@ it('setup forceRelease plugin', () => { const run = exec({force: 'foobar'}) return run.finally(() => { - expect(release).toBeCalledTimes(1) + expect(release).toHaveBeenCalledTimes(1) expect(release.mock.calls[0][0]).toMatchObject({ plugins: expect.arrayContaining([forceRelease]), }) @@ -153,7 +153,7 @@ it('setup initialRelease plugin', () => { const run = exec() return run.finally(() => { - expect(release).toBeCalledTimes(1) + expect(release).toHaveBeenCalledTimes(1) expect(release.mock.calls[0][0]).toMatchObject({ plugins: expect.arrayContaining([initialRelease]), }) @@ -211,8 +211,8 @@ it('call updateTag', () => { }}) return run.finally(() => { - expect(gitConfig).toBeCalled() - expect(updateTags).toBeCalledWith('HEAD', '1.2.3-foo.1', { + expect(gitConfig).toHaveBeenCalled() + expect(updateTags).toHaveBeenCalledWith('HEAD', '1.2.3-foo.1', { major: '1', minor: '2', patch: '3', diff --git a/test/plugin/forceRelease.ts b/test/plugin/forceRelease.ts index 6c750f9..496dc48 100644 --- a/test/plugin/forceRelease.ts +++ b/test/plugin/forceRelease.ts @@ -5,11 +5,11 @@ it('Return sanitized force release value', async () => { const { exec, logger } = setup(forceRelease.analyzeCommits) expect(await exec({}, {env: {RELEASE_FORCE: 'foo'}})).toBe('patch') - expect(logger.log).toBeCalledWith('Force release: %s', 'patch') + expect(logger.log).toHaveBeenCalledWith('Force release: %s', 'patch') expect(await exec({}, {env: {RELEASE_FORCE: ''}})).toBe(null) - expect(logger.log).not.toBeCalled() + expect(logger.log).not.toHaveBeenCalled() expect(await exec({}, {env: {RELEASE_FORCE: 'major'}})).toBe('major') - expect(logger.log).toBeCalledWith('Force release: %s', 'major') + expect(logger.log).toHaveBeenCalledWith('Force release: %s', 'major') }) diff --git a/test/plugin/initialRelease.ts b/test/plugin/initialRelease.ts index da4a543..f53c052 100644 --- a/test/plugin/initialRelease.ts +++ b/test/plugin/initialRelease.ts @@ -5,8 +5,8 @@ it('Return "patch" for initial release', async () => { const { exec, logger } = setup(initialRelease.analyzeCommits) expect(await exec({}, {})).toBe('patch') - expect(logger.log).toBeCalledWith('Initial release') + expect(logger.log).toHaveBeenCalledWith('Initial release') expect(await exec({}, {lastRelease: {gitHead: 'abcdef...', gitTag: 'v1.2.3', version: '1.2.3'}})).toBe(null) - expect(logger.log).not.toBeCalled() + expect(logger.log).not.toHaveBeenCalled() }) diff --git a/test/util/install.ts b/test/util/install.ts index 0f83102..9575d27 100644 --- a/test/util/install.ts +++ b/test/util/install.ts @@ -21,7 +21,7 @@ test('skip present modules', async () => { expect(resolveMock).toHaveBeenNthCalledWith(1, 'foo') expect(resolveMock).toHaveBeenNthCalledWith(2, 'bar') - expect(spawnMock).not.toBeCalled() + expect(spawnMock).not.toHaveBeenCalled() expect(log).toEqual(expect.arrayContaining([ expect.stringMatching('"foo" resolved'), expect.stringMatching('"bar" resolved'), @@ -37,7 +37,7 @@ test('install missing modules', async () => { expect(resolveMock).toHaveBeenNthCalledWith(1, 'foo') expect(resolveMock).toHaveBeenNthCalledWith(2, 'bar') - expect(spawnMock).toBeCalledTimes(1) + expect(spawnMock).toHaveBeenCalledTimes(1) expect(spawnMock.mock.calls[0][0]).toBe('npm') expect(spawnMock.mock.calls[0][1][0]).toBe('install') expect(spawnMock.mock.calls[0][1]).toContain('foo') @@ -50,7 +50,7 @@ test('install in dist', async () => { await install(['foo'], () => undefined) - expect(spawnMock).toBeCalledTimes(1) + expect(spawnMock).toHaveBeenCalledTimes(1) expect(spawnMock.mock.calls[0][2]).toEqual(expect.objectContaining({ // In test this should be the directory of the `install` util cwd: path.resolve(__dirname, '../../src/util'), diff --git a/test/util/spawn.ts b/test/util/spawn.ts index 764007a..0a171f5 100644 --- a/test/util/spawn.ts +++ b/test/util/spawn.ts @@ -21,7 +21,7 @@ test('defer args and options', () => { const child = spawn('foo', ['bar', 'baz'], {uid: 123456}) - expect(spawnMock).toBeCalledWith('foo', ['bar', 'baz'], {uid: 123456}) + expect(spawnMock).toHaveBeenCalledWith('foo', ['bar', 'baz'], {uid: 123456}) return expect(child).resolves.toBe('') }) @@ -35,7 +35,7 @@ test('reject on spawn error', () => { const child = spawn('foo', ['bar', 'baz'], {uid: 123456}) - expect(spawnMock).toBeCalledWith('foo', ['bar', 'baz'], {uid: 123456}) + expect(spawnMock).toHaveBeenCalledWith('foo', ['bar', 'baz'], {uid: 123456}) return expect(child).rejects.toMatch('ENOSUP') })