Skip to content

Commit

Permalink
chore(zora): improve type support
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzofox3 committed Jun 20, 2024
1 parent 22f72e8 commit 7e24f6a
Show file tree
Hide file tree
Showing 22 changed files with 37 additions and 36 deletions.
16 changes: 6 additions & 10 deletions zora/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,20 @@
"mocha"
],
"type": "module",
"main": "./dist/index.cjs",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/zora.d.ts",
"default": "./es.js"
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/zora.d.ts",
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./cjs": "./dist/index.cjs",
"./es": "./dist/index.js"
}
},
"types": "dist/zora.d.ts",
"main": "./dist/index.cjs",
"prettier": {
"singleQuote": true
},
Expand All @@ -49,8 +46,7 @@
"zora-assert": "*"
},
"files": [
"dist",
"es.js"
"dist"
],
"author": "@lorenzofox3 <Laurent RENARD>",
"license": "MIT",
Expand Down
9 changes: 6 additions & 3 deletions zora/rollup-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import dts from 'rollup-plugin-dts';

export default {
input: 'src/types/index.d.ts',
output: {
file: 'dist/zora.d.ts',
output: [{
file: 'dist/index.d.ts',
format: 'es',
},
},{
file: 'dist/index.d.cts',
format: 'cjs',
}],
plugins: [dts()],
};
2 changes: 1 addition & 1 deletion zora/test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { resolve, extname } from 'node:path';
import { readFile } from 'node:fs/promises';
import { readdirSync } from 'node:fs';
import { execPath as node } from 'node:process';
import { test } from 'zora';
import { test } from '../src/index.js';

const ONLY_ERROR = ['no_only_mode.js', 'no_only_mode_nested.js'];
const sampleRoot = resolve(process.cwd(), './test/samples/');
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/async.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from 'zora';
import { test } from '../../src/index.js';

const wait = (time) =>
new Promise((resolve) => {
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/bailout.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from 'zora';
import { test } from '../../src/index.js';

test('will not go to the end', (t) => {
t.ok(true, 'okay');
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/bailout_nested.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from 'zora';
import { test } from '../../src/index.js';

test('will not go to the end', (t) => {
t.ok(true, 'okay');
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/circular_ref_obj.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from 'zora';
import { test } from '../../src/index.js';

test('circular ref in diagnostic', (t) => {
const b = { key: 'prop' };
Expand Down
4 changes: 2 additions & 2 deletions zora/test/samples/custom_assertion.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Assert, test } from 'zora';
import { Assert, test } from '../../src/index.js';

Assert.isFoo = (value, description = 'should be "foo"') => ({
pass: value === 'foo',
expected: 'foo',
actual: value,
operator: 'isFoo',
description,
other: 'property',
other: 'property'
});

test('tester 1', (t) => {
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/failing.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from 'zora';
import { test } from '../../src/index.js';

test('tester 1', (t) => {
t.ok(true, 'assert1');
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/failing_nested.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from 'zora';
import { test } from '../../src/index.js';

test('tester 1', (t) => {
t.ok(true, 'assert1');
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/flush.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from 'zora';
import { test } from '../../src/index.js';

const wait = (time) =>
new Promise((resolve) => {
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/late_collect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from 'zora';
import { test } from '../../src/index.js';

test(`late collection`, async (t) => {
t.ok(true);
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/nested.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from 'zora';
import { test } from '../../src/index.js';

test('tester 1', (t) => {
t.ok(true, 'assert1');
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/nested_async.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from 'zora';
import { test } from '../../src/index.js';

const wait = (time) =>
new Promise((resolve) => {
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/no_only_mode.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, only } from 'zora';
import { test, only } from '../../src/index.js';

test('should not run', (t) => {
t.fail('I should not run ');
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/no_only_mode_nested.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, only } from 'zora';
import { test, only } from '../../src/index.js';

test('should not run', (t) => {
t.fail('I should not run ');
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/only.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { only, test } from 'zora';
import { only, test } from '../../src/index.js';

test('should not run', (t) => {
t.fail('I should not run ');
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/only_nested.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { only, test } from 'zora';
import { only, test } from '../../src/index.js';

test('should not run', (t) => {
t.fail('I should not run ');
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/simple.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from 'zora';
import { test } from '../../src/index.js';

test('tester 1', (t) => {
t.ok(true, 'assert1');
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/skip.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, skip } from 'zora';
import { test, skip } from '../../src/index.js';

test('hello world', (t) => {
t.ok(true);
Expand Down
2 changes: 1 addition & 1 deletion zora/test/samples/symbol.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from 'zora';
import { test } from '../../src/index.js';

test('symbol tester 1', (t) => {
t.equal(Symbol('foo'), Symbol('bar'), 'Symbol foo should equal Symbol bar');
Expand Down
8 changes: 5 additions & 3 deletions zora/test/samples/timeout.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { test } from 'zora';
import { test } from '../../src/index.js';
import { setTimeout } from 'node:timers/promises';

test(
'broken promise',
({ ok }) => {
return new Promise(() => {}).then(() => {
return new Promise(() => {
}).then(() => {
ok(true);
});
},
Expand All @@ -15,7 +16,8 @@ test('timeout in a nested test', ({ test }) => {
test(
'nested',
({ ok }) => {
return new Promise(() => {}).then(() => {
return new Promise(() => {
}).then(() => {
ok(true);
});
},
Expand Down

0 comments on commit 7e24f6a

Please sign in to comment.