Skip to content

Commit

Permalink
Extract testing code with putting another directory
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Sep 11, 2024
1 parent 7a73cbd commit 12de59f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/assert.ts → __tests__/assert.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { strictEqual, deepStrictEqual } from 'node:assert';
import { Temporal } from 'temporal-polyfill';
import { Options } from './schema.ts';
import { Options } from '../src/schema.ts';

export function jsonEqual(actual: unknown, expected: unknown) {
deepStrictEqual(JSON.parse(JSON.stringify(actual)), expected);
Expand Down
2 changes: 1 addition & 1 deletion src/snapshot.ts → __tests__/fixtures/snapshot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Check } from './schema.ts';
import { Check } from '../../src/schema.ts';

// https://github.com/kachick/wait-other-jobs/actions/runs/8679817057/job/23799347421?pr=764
// TODO: Update after #771
Expand Down
6 changes: 3 additions & 3 deletions src/report.test.ts → __tests__/report.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'node:test';
import assert from 'node:assert';
import { checks8679817057, checks92810686811WaitSuccessPolling1 } from './snapshot.ts';
import { Report, Summary, generateReport, getSummaries, readableDuration } from './report.ts';
import { omit } from './util.ts';
import { checks8679817057, checks92810686811WaitSuccessPolling1 } from './fixtures/snapshot.ts';
import { Report, Summary, generateReport, getSummaries, readableDuration } from '../src/report.ts';
import { omit } from '../src/util.ts';
import { Temporal } from 'temporal-polyfill';
import { jsonEqual } from './assert.ts';

Expand Down
2 changes: 1 addition & 1 deletion src/schema.test.ts → __tests__/schema.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert, { strictEqual, throws } from 'node:assert';
import { Durationable, Options, yamlPattern } from './schema.ts';
import { Durationable, Options, yamlPattern } from '../src/schema.ts';
import { Temporal } from 'temporal-polyfill';
import { durationEqual, optionsEqual } from './assert.ts';
import { z } from 'zod';
Expand Down
2 changes: 1 addition & 1 deletion src/wait.test.ts → __tests__/wait.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
MIN_JITTER_MILLISECONDS,
MAX_JITTER_MILLISECONDS,
getInterval,
} from './wait.ts';
} from '../src/wait.ts';
import test from 'node:test';
import assert from 'node:assert';
import { Temporal } from 'temporal-polyfill';
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { readdirSync } from 'node:fs';
import { join } from 'path';
import { execFileSync } from 'node:child_process';

const dirEnts = readdirSync('.', { encoding: 'utf-8', recursive: true, withFileTypes: true });
const dirEnts = readdirSync('__tests__', { encoding: 'utf-8', recursive: true, withFileTypes: true });
const testPaths = dirEnts.flatMap((dirent) => dirent.name.endsWith('.test.ts') ? [join(dirent.path, dirent.name)] : []);

console.log('Starting to run tests for', testPaths);
Expand Down

0 comments on commit 12de59f

Please sign in to comment.