Skip to content

Commit e4a9e5e

Browse files
committed
test: upgrade to oclif test v4 and add jest
1 parent 9180978 commit e4a9e5e

13 files changed

+7556
-6375
lines changed

.mocharc.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

jest.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { JestConfigWithTsJest } from 'ts-jest'
2+
3+
const jestConfig: JestConfigWithTsJest = {
4+
preset: 'ts-jest/presets/default-esm',
5+
}
6+
7+
export default jestConfig

package-lock.json

Lines changed: 7494 additions & 6255 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@
5050
"underscore.string": "^3.3.6"
5151
},
5252
"devDependencies": {
53+
"@jest/globals": "^29.7.0",
5354
"@oclif/prettier-config": "^0.2.1",
54-
"@oclif/test": "^3",
55+
"@oclif/test": "^4",
5556
"@types/adm-zip": "^0.5.5",
5657
"@types/archiver": "^6.0.2",
5758
"@types/chai": "^4",
5859
"@types/debug": "^4.1.12",
60+
"@types/jest": "^29.5.12",
5961
"@types/lodash.assign": "^4.2.9",
60-
"@types/mocha": "^10",
6162
"@types/node": "20.11.0",
6263
"@types/underscore.string": "^0.0.41",
6364
"chai": "^4",
@@ -66,9 +67,10 @@
6667
"eslint-config-oclif-typescript": "^3",
6768
"eslint-config-prettier": "^9.1.0",
6869
"eslint-plugin-jsdoc": "^48.0.2",
69-
"mocha": "^10",
70+
"jest": "^29.7.0",
7071
"oclif": "^4.1.3",
7172
"shx": "^0.3.4",
73+
"ts-jest": "^29.1.3",
7274
"ts-node": "^10.9.2",
7375
"tsx": "^4.7.3",
7476
"typescript": "^5"
@@ -96,7 +98,7 @@
9698
"posttest": "npm run lint",
9799
"prepack": "npm run build && oclif manifest && oclif readme",
98100
"prepare": "npm run build",
99-
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
101+
"test": "NODE_OPTIONS=--experimental-vm-modules npx jest",
100102
"version": "oclif readme && git add README.md"
101103
}
102-
}
104+
}

src/AuthCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Command } from '@oclif/core'
22
import axios from 'axios'
33
import createDebug from 'debug'
4-
import { CodeGenieConfig, getCodeGenieConfig, updateCodeGenieConfig } from './config.js'
5-
import { getOpenIdClient } from './openid-client.js'
4+
import { CodeGenieConfig, getCodeGenieConfig, updateCodeGenieConfig } from './config'
5+
import { getOpenIdClient } from './openid-client'
66

77
const API_ENDPOINT = process.env.API_ENDPOINT || 'https://api.codegenie.codes'
88
axios.defaults.baseURL = API_ENDPOINT

src/commands/generate.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { describe, expect, test } from '@jest/globals'
2+
import { runCommand } from '@oclif/test'
3+
4+
describe('generate', () => {
5+
test('help', async () => {
6+
const { stdout } = await runCommand(['generate', '--help'])
7+
expect(stdout).toMatch(/USAGE/)
8+
})
9+
})

src/commands/generate.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import axios, { AxiosError } from 'axios'
44
import AdmZip from 'adm-zip'
55
import { cosmiconfig } from 'cosmiconfig'
66
import createDebug from 'debug'
7-
import { awsCredentialsFileExists } from '../aws-creds.js'
8-
import sleep from '../sleep.js'
7+
import { awsCredentialsFileExists } from '../aws-creds'
8+
import sleep from '../sleep'
99
import { execSync } from 'node:child_process'
1010
import { cwd } from 'node:process'
11-
import { AppDefinition } from '../input/types.js'
12-
import { generateIcons } from '../generate-icons.js'
11+
import { AppDefinition } from '../input/types'
12+
import { generateIcons } from '../generate-icons'
1313
import { dirname, join, resolve } from 'node:path'
1414
import { inspect } from 'node:util'
1515
import { copyFile, mkdir } from 'node:fs/promises'
1616
import { fileURLToPath } from 'node:url'
17-
import { AuthCommand } from '../AuthCommand.js'
18-
import { convertCliAppDefinitionToDatabaseModel } from '../convert-cli-app-definition-to-database-model.js'
17+
import { AuthCommand } from '../AuthCommand'
18+
import { convertCliAppDefinitionToDatabaseModel } from '../convert-cli-app-definition-to-database-model'
1919
const __dirname = dirname(fileURLToPath(import.meta.url))
2020

2121
const debug = createDebug('codegenie:generate')

src/commands/login.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { Command, ux } from '@oclif/core'
44
import { generators } from 'openid-client'
55
import open from 'open'
66
import createDebug from 'debug'
7-
import sleep from '../sleep.js'
8-
import { updateCodeGenieConfig } from '../config.js'
9-
import { REDIRECT_URL, getOpenIdClient } from '../openid-client.js'
10-
import { getRandom } from '../get-random.js'
7+
import sleep from '../sleep'
8+
import { updateCodeGenieConfig } from '../config'
9+
import { REDIRECT_URL, getOpenIdClient } from '../openid-client'
10+
import { getRandom } from '../get-random'
1111

1212
const debug = createDebug('codegenie:Login')
1313

test/commands/generate.test.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

test/commands/login.test.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)