Skip to content

Commit 6706296

Browse files
committed
chore: convert tests to typescript
1 parent 0e941f9 commit 6706296

13 files changed

Lines changed: 22 additions & 15 deletions

.mocharc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
module.exports = {
22
parallel: true,
3+
spec: 'test/*.ts',
34
};

package.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@
4949
"fix": "eslint --fix && prettier . --write",
5050
"prepare": "npm run build",
5151
"pretest": "eslint && prettier . --check",
52-
"test": "c8 esmocha --forbid-only",
53-
"test-base": "c8 esmocha test/environment*.js test/store.js test/util.js test/adapter.js",
54-
"test-environment": "c8 esmocha test/environment.js",
55-
"test-generators": "c8 esmocha test/generators.js",
56-
"test-resolver": "c8 esmocha test/resolver.js"
52+
"test": "c8 esmocha --forbid-only"
5753
},
5854
"config": {
5955
"doc_path": "./yeoman-environment-doc"
@@ -115,12 +111,12 @@
115111
"@yeoman/types": "^1.10.3",
116112
"mem-fs": "^4.1.4"
117113
},
118-
"acceptDependencies": {
119-
"@yeoman/adapter": ">=4.0.2"
120-
},
121114
"engines": {
122115
"node": "^20.17.0 || >=22.9.0"
123116
},
117+
"acceptDependencies": {
118+
"@yeoman/adapter": ">=4.0.2"
119+
},
124120
"overrides": {
125121
"yeoman-generator-2": {
126122
"chalk": "^4.1.0",

test/command.js renamed to test/command.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import assert from 'node:assert';
22
import path, { dirname } from 'node:path';
33
import { fileURLToPath } from 'node:url';
4-
import { createRequire } from 'node:module';
54
import { stub } from 'sinon';
65
import { beforeEach, describe, esmocha, expect, it } from 'esmocha';
76
import { TestAdapter } from 'yeoman-test';
87
import { prepareCommand } from '../src/commands.ts';
98
import Environment from '../src/index.ts';
109

11-
const require = createRequire(import.meta.url);
1210
const __filename = fileURLToPath(import.meta.url);
1311
const __dirname = dirname(__filename);
1412

@@ -170,7 +168,7 @@ describe('environment (command)', () => {
170168

171169
beforeEach(async () => {
172170
const command = await prepareCommand({
173-
resolved: require.resolve('./fixtures/generator-commands/generators/arguments/index.js'),
171+
resolved: fileURLToPath(new URL('fixtures/generator-commands/generators/arguments/index.js', import.meta.url)),
174172
});
175173
await command.parseAsync(['node', 'yo', 'bar']);
176174

@@ -191,7 +189,9 @@ describe('environment (command)', () => {
191189
let environment;
192190

193191
beforeEach(async () => {
194-
const command = await prepareCommand({ resolved: require.resolve('./fixtures/generator-commands/generators/options/index.js') });
192+
const command = await prepareCommand({
193+
resolved: fileURLToPath(new URL('fixtures/generator-commands/generators/options/index.js', import.meta.url)),
194+
});
195195
await command.parseAsync([
196196
'node',
197197
'yo',
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { spy, stub } from 'sinon';
1212
import assert from 'yeoman-assert';
1313
import Environment, { createEnv as createEnvironment } from '../src/index.ts';
1414
import { resolveModulePath } from '../src/util/resolve.ts';
15-
import { allVersions, importGenerator, isGreaterThan6, isLegacyVersion } from './generator-versions.js';
15+
import { allVersions, importGenerator, isGreaterThan6, isLegacyVersion } from './generator-versions.ts';
1616

1717
const require = createRequire(import.meta.url);
1818

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import assert from 'node:assert';
22
import { stub } from 'sinon';
33
import { after, afterEach, before, beforeEach, describe, esmocha, expect, it } from 'esmocha';
4-
import helpers, { getCreateEnv as getCreateEnvironment, result } from './helpers.js';
5-
import { greaterThan5 } from './generator-versions.js';
4+
import helpers, { getCreateEnv as getCreateEnvironment, result } from './helpers.ts';
5+
import { greaterThan5 } from './generator-versions.ts';
66

77
const commitModule = await import('../src/commit.ts');
88
const { commitSharedFsTask: originalCommitSharedFsTask } = commitModule;
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)