Skip to content

Commit

Permalink
test: use node --test
Browse files Browse the repository at this point in the history
Don't install another devDependency for something that is built in now
  • Loading branch information
EdJoPaTo committed Nov 27, 2023
1 parent f367058 commit 6cafb8f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"scripts": {
"build": "del-cli dist && tsc",
"prepack": "npm run build",
"test": "tsc --sourceMap && xo && c8 --all ava"
"test": "tsc --sourceMap && xo && c8 --all node --test --enable-source-maps"
},
"type": "module",
"engines": {
Expand All @@ -27,28 +27,28 @@
"dependencies": {},
"devDependencies": {
"@sindresorhus/tsconfig": "^5.0.0",
"@types/node": "^14.18.56",
"ava": "^5.0.1",
"@types/node": "^18.18.13",
"c8": "^8.0.1",
"del-cli": "^5.0.0",
"typescript": "^5.0.2",
"xo": "^0.56.0"
},
"files": [
"dist",
"!*.test.*"
"!*.test.*",
"!test.*"
],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"xo": {
"rules": {
"@typescript-eslint/prefer-readonly-parameter-types": "warn",
"ava/no-ignored-test-files": "off"
"@typescript-eslint/prefer-readonly-parameter-types": "warn"
},
"overrides": [
{
"files": [
"**/*.test.*"
"**/*.test.*",
"**/test.*"
],
"rules": {
"@typescript-eslint/prefer-readonly-parameter-types": "off"
Expand Down
15 changes: 0 additions & 15 deletions source/index.test.ts

This file was deleted.

14 changes: 14 additions & 0 deletions source/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {strictEqual, throws} from 'node:assert';
import {test} from 'node:test';
import {moduleName} from './index.js';

await test('simple string input', () => {
strictEqual(moduleName('unicorns'), 'unicorns & rainbows');
});

await test('javascript users without typings get error on number', () => {
// @ts-expect-error moduleName expects a string not a number
throws(() => moduleName(123), {
message: 'Expected a string, got number',
});
});

0 comments on commit 6cafb8f

Please sign in to comment.