-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
219 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
/node_modules | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.tabSize": 2, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": "explicit", | ||
"quickfix.biome": "explicit" | ||
}, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "biomejs.biome" | ||
}, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "biomejs.biome" | ||
}, | ||
"[json]": { | ||
"editor.defaultFormatter": "biomejs.biome" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.7.1/schema.json", | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"quoteStyle": "single", | ||
"semicolons": "asNeeded", | ||
"bracketSpacing": false, | ||
"trailingComma": "none", | ||
"arrowParentheses": "asNeeded" | ||
} | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"formatWithErrors": false, | ||
"indentStyle": "space", | ||
"indentWidth": 2, | ||
"lineWidth": 80, | ||
"lineEnding": "lf", | ||
"ignore": [] | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"correctness": { | ||
"noConstructorReturn": "off" | ||
}, | ||
"style": { | ||
"noNonNullAssertion": "off", | ||
"useEnumInitializers": "off", | ||
"noParameterAssign": "off", | ||
"useShorthandFunctionType": "off" | ||
}, | ||
"complexity": { | ||
"noBannedTypes": "off" | ||
}, | ||
"suspicious": { | ||
"noExplicitAny": "off", | ||
"noConstEnum": "off", | ||
"noAssignInExpressions": "off", | ||
"noConfusingLabels": "off", | ||
"noExportsInTest": "off" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[install.scopes] | ||
"@jsr" = "https://npm.jsr.io" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"imports": { | ||
"#suite": "./dist/suite.deno.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"name": "@benmerckx/suite", | ||
"version": "0.2.0", | ||
"exports": "./mod.ts" | ||
} | ||
"version": "0.3.0", | ||
"exports": "./jsr.ts", | ||
"publish": { | ||
"exclude": ["!dist"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type {Suite} from './src/suite' | ||
|
||
/** Define a test suite */ | ||
export const suite: Suite = ( | ||
await ('Bun' in globalThis | ||
? import('./src/suite.bun.js') | ||
: 'Deno' in globalThis | ||
? import('./dist/suite.deno.js') | ||
: import('./src/suite.node.js')) | ||
).suite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,39 @@ | ||
{ | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"name": "@benmerckx/suite", | ||
"module": "suite.js", | ||
"types": "suite.d.ts", | ||
"type": "module", | ||
"files": [ | ||
"suite.js", | ||
"suite.d.ts" | ||
], | ||
"files": ["./dist", "./src"], | ||
"devDependencies": { | ||
"@jsr/std__assert": "^0.225.2", | ||
"@types/bun": "latest" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
}, | ||
"scripts": { | ||
"build": "bun build src/suite.deno.js --outdir=dist --minify", | ||
"test": "node --test && deno test && bun test", | ||
"deploy": "npm publish && npx jsr publish" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"exports": { | ||
".": { | ||
"deno": "./dist/suite.deno.js", | ||
"bun": "./src/suite.bun.js", | ||
"node": "./src/suite.node.js", | ||
"types": "./src/suite.d.ts" | ||
} | ||
}, | ||
"imports": { | ||
"#suite": { | ||
"deno": "./dist/suite.deno.js", | ||
"bun": "./src/suite.bun.js", | ||
"node": "./src/suite.node.js", | ||
"types": "./src/suite.d.ts" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export function setup(meta) { | ||
// @ts-ignore | ||
const native = Bun.jest(meta.path) | ||
const test = native.test.bind() | ||
test.skip = native.test.skip | ||
test.only = native.test.only | ||
test.ok = a => native.expect(a).toBeTruthy() | ||
test.is = (a, b) => native.expect(a).toBe(b) | ||
test.equal = (a, b) => native.expect(a).toEqual(b) | ||
test.throws = (fn, err) => | ||
err === undefined | ||
? native.expect(fn).toThrow() | ||
: native.expect(fn).toThrow(err) | ||
test.not = { | ||
ok: a => native.expect(a).toBeFalsy(), | ||
is: (a, b) => native.expect(a).not.toBe(b), | ||
equal: (a, b) => native.expect(a).not.toEqual(b) | ||
} | ||
return test | ||
} | ||
|
||
export const suite = (meta, define) => define(setup(meta)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
/** Describe a test */ | ||
export type Describe = | ||
(name: string, run: ()=> void | Promise<void>) => void | ||
|
||
/** Define a test suite */ | ||
export interface DefineTest extends Describe { | ||
/** Skip the test */ | ||
skip: Describe | ||
/** Only run this test */ | ||
only: Describe | ||
/** Assert that actual is a truthy value */ | ||
ok(actual: any): void | ||
/** Assert that actual strictly equals (===) the expects value */ | ||
is(actual: any, expects: any): void | ||
/** Assert that actual is deeply equal to the expects value */ | ||
equal(actual: any, expects: any): void | ||
/** Assert that the fn function throws an Error */ | ||
throws(fn: () => void, messageIncludes?: string): void | ||
/** Assert inverse */ | ||
not: { | ||
/** Assert that actual is a falsy value */ | ||
ok(actual: any): void | ||
/** Assert that actual does not strictly equal (===) the expects value */ | ||
is(actual: any, expects: any): void | ||
/** Assert that actual is not deeply equal to the expects value */ | ||
equal(actual: any, expects: any): void | ||
} | ||
} | ||
|
||
/** Define a test suite */ | ||
export type Suite = | ||
(meta: ImportMeta, define: (test: DefineTest) => void) => void | ||
|
||
/** Define a test suite */ | ||
/** Describe a test */ | ||
export type Describe = (name: string, run: () => void | Promise<void>) => void | ||
|
||
/** Define a test suite */ | ||
export interface DefineTest extends Describe { | ||
/** Skip the test */ | ||
skip: Describe | ||
/** Only run this test */ | ||
only: Describe | ||
/** Assert that actual is a truthy value */ | ||
ok(actual: any): void | ||
/** Assert that actual strictly equals (===) the expects value */ | ||
is(actual: any, expects: any): void | ||
/** Assert that actual is deeply equal to the expects value */ | ||
equal(actual: any, expects: any): void | ||
/** Assert that the fn function throws an Error */ | ||
throws(fn: () => void, messageIncludes?: string): void | ||
/** Assert inverse */ | ||
not: { | ||
/** Assert that actual is a falsy value */ | ||
ok(actual: any): void | ||
/** Assert that actual does not strictly equal (===) the expects value */ | ||
is(actual: any, expects: any): void | ||
/** Assert that actual is not deeply equal to the expects value */ | ||
equal(actual: any, expects: any): void | ||
} | ||
} | ||
|
||
/** Define a test suite */ | ||
export interface Suite { | ||
(meta: ImportMeta, define: (test: DefineTest) => void): void | ||
// runtime: 'node' | 'deno' | 'bun' | ||
} | ||
|
||
export const suite: Suite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { | ||
assert, | ||
assertEquals, | ||
assertFalse, | ||
assertNotEquals, | ||
assertNotStrictEquals, | ||
assertStrictEquals, | ||
assertThrows | ||
} from '../node_modules/@jsr/std__assert/mod.js' | ||
|
||
// @ts-ignore | ||
const native = Deno.test | ||
const test = native.bind() | ||
test.skip = native.ignore | ||
test.only = native.only | ||
test.ok = assert | ||
test.is = assertStrictEquals | ||
test.equal = assertEquals | ||
test.throws = assertThrows | ||
test.not = { | ||
ok: assertFalse, | ||
is: assertNotStrictEquals, | ||
equal: assertNotEquals | ||
} | ||
|
||
export const suite = (meta, define) => define(test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as asserts from 'node:assert' | ||
import * as native from 'node:test' | ||
|
||
const test = native.test.bind() | ||
test.skip = native.skip | ||
test.only = native.only | ||
test.ok = asserts.ok | ||
test.is = asserts.strictEqual | ||
test.equal = asserts.deepStrictEqual | ||
test.throws = asserts.throws | ||
test.not = { | ||
ok: a => asserts.ok(!a), | ||
is: asserts.notStrictEqual, | ||
equal: asserts.notDeepStrictEqual | ||
} | ||
|
||
export const suite = (meta, define) => define(test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters