Skip to content

Commit

Permalink
Update, suggest only using npm, add node:test tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoDF committed Sep 10, 2023
1 parent 8d37bfc commit 8da86e6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, lint, and test
- name: npm install and test
run: |
npm ci
# npm run build
# npm test
env:
CI: true
npm test
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# [Project Name]

Boilerplate repo with:

- MIT License
- Node, npm
- tests with the `node:test` built-in
- formatting with prettier
- GitHub Actions

## Requirements

- Node 10
- Yarn 1.x or npm
- Node 20
- npm v8+

## Setup

Expand All @@ -10,9 +20,7 @@

## npm scripts

> Equivalent `npm run <script>` should also work
- `yarn lint` will lint all of the files with [xo](https://github.com/xojs/xo)
- `npm test` will run tests using the [Node.js test runner](https://nodejs.org/api/test.html#running-tests-from-the-command-line) and the `node:test` module.
- `npm run format` will run prettier on all the examples files (and tests).

## LICENSE
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"private": true,
"type": "module",
"scripts": {
"test": "node --test",
"format": "prettier --write './**/*.{js,json,yml,md}'"
},
"license": "MIT",
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function add(a, b) {
return a + b;
}
7 changes: 7 additions & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { add } from "./index.js";

test("add", () => {
assert.equal(add(1, 2), 3);
});

0 comments on commit 8da86e6

Please sign in to comment.