Skip to content

Commit

Permalink
refact, please ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
npmstudy committed Sep 26, 2023
1 parent 2ae52d8 commit 4762d33
Show file tree
Hide file tree
Showing 13 changed files with 704 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"reporter": [
"lcov",
"text",
"html"
]
}
23 changes: 23 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Node.js CI

on: ["push", "pull_request"]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "20.x"
- run: npm install
- run: npm test
- run: npm run test:coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./coverage/lcov.info
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"connor4312.nodejs-testing",
"yoavbls.pretty-ts-errors"
]
}
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Unit test",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}",
"args": [
"--loader",
"tsx",
"--test"
]
},
{
"name": "Attach to tsx",
"port": 9229,
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Your first Node.js Helloworld with TypeScript

![build status](https://github.com/npmstudy/node-v20-helloworld/actions/workflows/main.yml/badge.svg) [![codecov](https://codecov.io/github/npmstudy/node-v20-helloworld/graph/badge.svg?token=CSMN20E3W4)](https://codecov.io/github/npmstudy/node-v20-helloworld)

- use Node.js v20 test runner
- use c8 for coverage


## What is in this repository?

- use [tsx](https://github.com/esbuild-kit/tsx) as typescript register & executor
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface IPerson {
say(name: string): void;
sayHi(name?: string): Promise<void>;
}
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import { HelloWorld } from "./src/helloworld";

const cli: IPerson = new HelloWorld();

expectType<void>(cli.say("use TypeScript to write Node.js"));
expectType<Promise<void>>(cli.sayHi("use TypeScript to write Node.js"));
Loading

0 comments on commit 4762d33

Please sign in to comment.