Skip to content

Commit dc25973

Browse files
committed
CCM-12896: Revert doc test change to tsx
1 parent b45c516 commit dc25973

File tree

6 files changed

+82
-25
lines changed

6 files changed

+82
-25
lines changed

package-lock.json

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

src/cloudevents/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"jest": "^30.2.0",
1717
"json-schema-static-docs": "^0.28.1",
1818
"ts-jest": "^29.4.5",
19+
"ts-node": "^10.0.0",
1920
"tsx": "^4.20.6",
2021
"typescript": "^5.0.0"
2122
},

src/cloudevents/tools/builder/__tests__/build-schema.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('build-schema CLI', () => {
5050
// Run build-schema
5151
try {
5252
execSync(
53-
`tsx tools/builder/build-schema.ts "${inputFile}" "${outputDir}"`,
53+
`ts-node tools/builder/build-schema.ts "${inputFile}" "${outputDir}"`,
5454
{
5555
cwd: process.cwd(),
5656
stdio: 'pipe'
@@ -89,7 +89,7 @@ properties:
8989

9090
try {
9191
execSync(
92-
`tsx tools/builder/build-schema.ts "${inputFile}" "${outputDir}"`,
92+
`ts-node tools/builder/build-schema.ts "${inputFile}" "${outputDir}"`,
9393
{
9494
cwd: process.cwd(),
9595
stdio: 'pipe'
@@ -118,7 +118,7 @@ properties:
118118

119119
try {
120120
const result = execSync(
121-
`tsx tools/builder/build-schema.ts "${inputFile}" "${outputDir}"`,
121+
`ts-node tools/builder/build-schema.ts "${inputFile}" "${outputDir}"`,
122122
{
123123
cwd: process.cwd(),
124124
stdio: 'pipe',
@@ -137,7 +137,7 @@ properties:
137137
it('should handle missing arguments gracefully', () => {
138138
try {
139139
execSync(
140-
'tsx tools/builder/build-schema.ts',
140+
'ts-node tools/builder/build-schema.ts',
141141
{
142142
cwd: process.cwd(),
143143
stdio: 'pipe'
@@ -158,7 +158,7 @@ properties:
158158

159159
try {
160160
execSync(
161-
`tsx tools/builder/build-schema.ts "${inputFile}" "${outputDir}" "https://example.com"`,
161+
`ts-node tools/builder/build-schema.ts "${inputFile}" "${outputDir}" "https://example.com"`,
162162
{
163163
cwd: process.cwd(),
164164
stdio: 'pipe'
@@ -196,7 +196,7 @@ properties:
196196
try {
197197
// Build the main schema
198198
execSync(
199-
`tsx tools/builder/build-schema.ts "${mainFile}" "${outputDir}"`,
199+
`ts-node tools/builder/build-schema.ts "${mainFile}" "${outputDir}"`,
200200
{
201201
cwd: process.cwd(),
202202
stdio: 'pipe'
@@ -222,7 +222,7 @@ properties:
222222

223223
try {
224224
execSync(
225-
`tsx tools/builder/build-schema.ts "${yamlFile}" "${outputDir}"`,
225+
`ts-node tools/builder/build-schema.ts "${yamlFile}" "${outputDir}"`,
226226
{
227227
cwd: process.cwd(),
228228
stdio: 'pipe'
@@ -244,7 +244,7 @@ properties:
244244
it('should handle non-existent input file', () => {
245245
try {
246246
execSync(
247-
`tsx tools/builder/build-schema.ts "nonexistent.json" "${outputDir}"`,
247+
`ts-node tools/builder/build-schema.ts "nonexistent.json" "${outputDir}"`,
248248
{
249249
cwd: process.cwd(),
250250
stdio: 'pipe'
@@ -264,7 +264,7 @@ properties:
264264

265265
try {
266266
execSync(
267-
`tsx tools/builder/build-schema.ts "${invalidFile}" "${outputDir}"`,
267+
`ts-node tools/builder/build-schema.ts "${invalidFile}" "${outputDir}"`,
268268
{
269269
cwd: process.cwd(),
270270
stdio: 'pipe'

src/cloudevents/tools/discovery/__tests__/discover-schema-dependencies.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ describe('discover-schema-dependencies CLI', () => {
3131
describe('CLI argument validation', () => {
3232
it('should exit with error when no arguments provided', () => {
3333
expect(() => {
34-
execSync(`npx tsx ${SCRIPT_PATH}`, { encoding: 'utf-8', stdio: 'pipe' });
34+
execSync(`npx ts-node ${SCRIPT_PATH}`, { encoding: 'utf-8', stdio: 'pipe' });
3535
}).toThrow();
3636
});
3737

3838
it('should exit with error when only one argument provided', () => {
3939
expect(() => {
40-
execSync(`npx tsx ${SCRIPT_PATH} /some/path`, {
40+
execSync(`npx ts-node ${SCRIPT_PATH} /some/path`, {
4141
encoding: 'utf-8',
4242
stdio: 'pipe',
4343
});
@@ -49,7 +49,7 @@ describe('discover-schema-dependencies CLI', () => {
4949
const outputDir = path.join(tempDir, 'output');
5050

5151
expect(() => {
52-
execSync(`npx tsx ${SCRIPT_PATH} ${nonExistentPath} ${outputDir}`, {
52+
execSync(`npx ts-node ${SCRIPT_PATH} ${nonExistentPath} ${outputDir}`, {
5353
encoding: 'utf-8',
5454
stdio: 'pipe',
5555
});
@@ -77,7 +77,7 @@ properties:
7777
const outputDir = path.join(tempDir, 'output');
7878
fs.mkdirSync(outputDir, { recursive: true });
7979

80-
const result = execSync(`npx tsx ${SCRIPT_PATH} ${schemaPath} ${outputDir}`, {
80+
const result = execSync(`npx ts-node ${SCRIPT_PATH} ${schemaPath} ${outputDir}`, {
8181
encoding: 'utf-8',
8282
});
8383

@@ -126,7 +126,7 @@ properties:
126126
const outputDir = path.join(tempDir, 'output');
127127
fs.mkdirSync(outputDir, { recursive: true });
128128

129-
const result = execSync(`npx tsx ${SCRIPT_PATH} ${schemaPath} ${outputDir}`, {
129+
const result = execSync(`npx ts-node ${SCRIPT_PATH} ${schemaPath} ${outputDir}`, {
130130
encoding: 'utf-8',
131131
});
132132

@@ -178,7 +178,7 @@ properties:
178178
fs.mkdirSync(outputDir, { recursive: true });
179179

180180
// Should complete without hanging or error
181-
const result = execSync(`npx tsx ${SCRIPT_PATH} ${schemaAPath} ${outputDir}`, {
181+
const result = execSync(`npx ts-node ${SCRIPT_PATH} ${schemaAPath} ${outputDir}`, {
182182
encoding: 'utf-8',
183183
timeout: 5000, // 5 second timeout to catch infinite loops
184184
});
@@ -209,7 +209,7 @@ properties:
209209
const outputDir = path.join(tempDir, 'output');
210210
fs.mkdirSync(outputDir, { recursive: true });
211211

212-
const result = execSync(`npx tsx ${SCRIPT_PATH} ${schemaPath} ${outputDir}`, {
212+
const result = execSync(`npx ts-node ${SCRIPT_PATH} ${schemaPath} ${outputDir}`, {
213213
encoding: 'utf-8',
214214
});
215215

@@ -236,7 +236,7 @@ properties:
236236
const outputDir = path.join(tempDir, 'output');
237237
fs.mkdirSync(outputDir, { recursive: true });
238238

239-
const result = execSync(`npx tsx ${SCRIPT_PATH} ${schemaPath} ${outputDir}`, {
239+
const result = execSync(`npx ts-node ${SCRIPT_PATH} ${schemaPath} ${outputDir}`, {
240240
encoding: 'utf-8',
241241
});
242242

@@ -276,7 +276,7 @@ properties:
276276
const outputDir = path.join(tempDir, 'output');
277277
fs.mkdirSync(outputDir, { recursive: true });
278278

279-
const result = execSync(`npx tsx ${SCRIPT_PATH} ${schema1Path} ${outputDir}`, {
279+
const result = execSync(`npx ts-node ${SCRIPT_PATH} ${schema1Path} ${outputDir}`, {
280280
encoding: 'utf-8',
281281
});
282282

@@ -310,7 +310,7 @@ properties:
310310
const outputDir = path.join(tempDir, 'output');
311311
fs.mkdirSync(outputDir, { recursive: true });
312312

313-
const result = execSync(`npx tsx ${SCRIPT_PATH} ${eventPath} ${outputDir}`, {
313+
const result = execSync(`npx ts-node ${SCRIPT_PATH} ${eventPath} ${outputDir}`, {
314314
encoding: 'utf-8',
315315
});
316316

src/cloudevents/tools/generator/__tests__/generate-example.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import http from 'http';
1111

1212
const SCRIPT_PATH = path.join(__dirname, '..', 'example-generator', 'generate-example.ts');
1313
const TEST_DIR = path.join(__dirname, 'temp-generate-example-test');
14-
// Use npx to run tsx, which will find it in the root workspace
15-
const TS_NODE_CMD = 'npx tsx';
14+
// Use npx to run ts-node, which will find it in the root workspace
15+
const TS_NODE_CMD = 'npx ts-node';
1616

1717
describe('generate-example.ts', () => {
1818
let server: http.Server | undefined;

src/cloudevents/tools/validator/__tests__/validate.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ const TEST_DIR = path.join(__dirname, 'temp-validate-test');
1717
function runValidator(schemaPath: string, dataPath: string, baseDir?: string): { success: boolean; output: string; error: string } {
1818
try {
1919
const args = baseDir ? ['--base', baseDir, schemaPath, dataPath] : [schemaPath, dataPath];
20-
const result = spawnSync('npx', ['tsx', SCRIPT_PATH, ...args], {
20+
const result = spawnSync('npx', ['ts-node', SCRIPT_PATH, ...args], {
2121
encoding: 'utf-8',
22-
timeout: 10000 // Increased timeout for tsx
22+
timeout: 10000 // Increased timeout for ts-node
2323
});
2424

2525
return {
@@ -53,7 +53,7 @@ describe('validate.ts', () => {
5353

5454
describe('command line arguments', () => {
5555
it('should exit with error when no arguments provided', () => {
56-
const result = spawnSync('npx', ['tsx', SCRIPT_PATH], { encoding: 'utf-8', timeout: 10000 });
56+
const result = spawnSync('npx', ['ts-node', SCRIPT_PATH], { encoding: 'utf-8', timeout: 10000 });
5757
expect(result.status).not.toBe(0);
5858
expect(result.stderr).toContain('Usage:');
5959
});
@@ -62,7 +62,7 @@ describe('validate.ts', () => {
6262
const schemaFile = path.join(TEST_DIR, 'schema.json');
6363
fs.writeFileSync(schemaFile, JSON.stringify({ type: 'object' }));
6464

65-
const result = spawnSync('npx', ['tsx', SCRIPT_PATH, schemaFile], { encoding: 'utf-8', timeout: 10000 });
65+
const result = spawnSync('npx', ['ts-node', SCRIPT_PATH, schemaFile], { encoding: 'utf-8', timeout: 10000 });
6666
expect(result.status).not.toBe(0);
6767
expect(result.stderr).toContain('Usage:');
6868
});

0 commit comments

Comments
 (0)