Skip to content

Commit b255e75

Browse files
committed
Fix failing tests
1 parent 65fa51e commit b255e75

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

packages/rtk-query-codegen-openapi/test/cli.test.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import path from 'node:path';
66

77
function cli(args: string[], cwd: string): Promise<{ error: ExecException | null; stdout: string; stderr: string }> {
88
const pwd = process.env?.PWD || '.';
9-
const cmd = `${require.resolve('ts-node/dist/bin')} -T -P ${path.resolve(pwd, 'tsconfig.json')} ${path.resolve(
10-
pwd,
11-
'src/bin/cli.ts'
12-
)} ${args.join(' ')}`;
9+
const cmd = `yarn cli ${args.join(' ')}`;
1310
return new Promise((resolve) => {
1411
exec(cmd, { cwd }, (error, stdout, stderr) => {
1512
resolve({
@@ -21,7 +18,7 @@ function cli(args: string[], cwd: string): Promise<{ error: ExecException | null
2118
});
2219
}
2320

24-
const tmpDir = path.resolve(__dirname, 'tmp');
21+
const tmpDir = path.join(__dirname, 'tmp');
2522

2623
beforeAll(async () => {
2724
if (!fs.existsSync(tmpDir)) fs.mkdirSync(tmpDir, { recursive: true });
@@ -32,8 +29,8 @@ afterEach(() => {
3229
});
3330

3431
describe('CLI options testing', () => {
35-
test.todo('generation with `config.example.js`', async () => {
36-
const out = await cli([`./config.example.js`], __dirname);
32+
test('generation with `config.example.js`', async () => {
33+
const out = await cli(['./test/config.example.js'], __dirname);
3734

3835
expect(out).toEqual({
3936
stdout: `Generating ./tmp/example.ts
@@ -46,8 +43,8 @@ Done
4643
expect(fs.readFileSync(path.resolve(tmpDir, 'example.ts'), 'utf-8')).toMatchSnapshot();
4744
}, 25_000);
4845

49-
test.todo('paths are relative to configfile, not to cwd', async () => {
50-
const out = await cli([`../test/config.example.js`], path.resolve(__dirname, '../src'));
46+
test('paths are relative to config file, not to cwd', async () => {
47+
const out = await cli([`./test/config.example.js`], path.resolve(__dirname, '../src'));
5148

5249
expect(out).toEqual({
5350
stdout: `Generating ./tmp/example.ts
@@ -60,20 +57,20 @@ Done
6057
expect(fs.readFileSync(path.resolve(tmpDir, 'example.ts'), 'utf-8')).toMatchSnapshot();
6158
}, 25_000);
6259

63-
test.todo('ts, js and json all work the same', async () => {
64-
await cli([`./config.example.js`], __dirname);
60+
test('ts, js and json all work the same', async () => {
61+
await cli([`./test/config.example.js`], __dirname);
6562
const fromJs = fs.readFileSync(path.resolve(tmpDir, 'example.ts'), 'utf-8');
66-
await cli([`./config.example.ts`], __dirname);
63+
await cli([`./test/config.example.ts`], __dirname);
6764
const fromTs = fs.readFileSync(path.resolve(tmpDir, 'example.ts'), 'utf-8');
68-
await cli([`./config.example.json`], __dirname);
65+
await cli([`./test/config.example.json`], __dirname);
6966
const fromJson = fs.readFileSync(path.resolve(tmpDir, 'example.ts'), 'utf-8');
7067

7168
expect(fromTs).toEqual(fromJs);
7269
expect(fromJson).toEqual(fromJs);
7370
}, 120_000);
7471

75-
test.todo('missing parameters doesnt fail', async () => {
76-
const out = await cli([`./config.invalid-example.json`], __dirname);
72+
test("missing parameters doesn't fail", async () => {
73+
const out = await cli([`./test/config.invalid-example.json`], __dirname);
7774
expect(out.stderr).toContain("Error: path parameter petId does not seem to be defined in '/pet/{petId}'!");
7875
}, 25_000);
7976
});

0 commit comments

Comments
 (0)