Skip to content

Commit

Permalink
Add tests scaffold, linting and GitHub workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
aldipower committed Oct 9, 2024
1 parent 95510be commit 855d71a
Show file tree
Hide file tree
Showing 7 changed files with 1,984 additions and 38 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
30 changes: 30 additions & 0 deletions .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Reboot.dev Node.js Template

on: [push]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint sources
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'npm'
- run: npm ci
- run: npm run lint

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run all tests
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'npm'
- run: npm ci
- run: npm run test
4 changes: 2 additions & 2 deletions backend/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Application } from "@reboot-dev/reboot";
import { Application, ExternalContext } from "@reboot-dev/reboot";

const initialize = async (context) => {};
const initialize = async (context: ExternalContext) => {};

Check failure on line 3 in backend/src/main.ts

View workflow job for this annotation

GitHub Actions / Lint

'context' is defined but never used

new Application({
servicers: [],
Expand Down
25 changes: 25 additions & 0 deletions backend/tests/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ExternalContext, Reboot } from "@reboot-dev/reboot";
import { describe, it, before, after } from "node:test";
import assert from "node:assert";

describe("Main Application", async () => {
let context: ExternalContext;
let rbt: Reboot;

before(async () => {
rbt = new Reboot();
await rbt.start();
await rbt.up([]);
context = rbt.createExternalContext("test-runner");
});

after(async () => {
await rbt.stop();
});

describe("Servicer", () => {
it("does not throw", async () => {
assert.ok(context);
});
});
});
9 changes: 9 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
);
Loading

0 comments on commit 855d71a

Please sign in to comment.