Skip to content

Commit

Permalink
feat(test): moving unit testing over to vitest (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion authored May 25, 2024
1 parent 741f9c8 commit 6f3926d
Show file tree
Hide file tree
Showing 114 changed files with 6,167 additions and 16,730 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

56 changes: 56 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"root": true,
"extends": [
"@readme/eslint-config",
"@readme/eslint-config/typescript"
],
"parserOptions": {
"ecmaVersion": 2020
},
"env": {
"node": true,
"browser": true
},
"rules": {
"consistent-return": "off",
"no-plusplus": "off",
"no-restricted-syntax": "off",
"no-underscore-dangle": "off",
"no-unused-vars": "off",
"no-use-before-define": "off",
"node/no-deprecated-api": "off", // `url.parse` has been deprecated but `url.URL` isn't a good replacement yet.
"prefer-rest-params": "off"
},
"overrides": [
{
// The typings in this file are pretty bad right now, when we have native types we can
// remove this.
"files": ["lib/index.d.ts"],
"rules": {
"@typescript-eslint/array-type": "off",
"@typescript-eslint/consistent-indexed-object-style": "off",
"@typescript-eslint/consistent-type-imports": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/sort-type-constituents": "off",
"eslint-comments/no-unused-disable": "off",
"lines-between-class-members": "off",
"max-classes-per-file": "off",
"typescript-sort-keys/interface": "off",
"unicorn/custom-error-definition": "off"
}
},
{
// These can all get removed when the library is moved over to native TS.
"files": ["*.js"],
"rules": {
"@typescript-eslint/no-shadow": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "off",
"func-names": "off",
"no-unused-expressions": "off"
}
}
],
}
18 changes: 0 additions & 18 deletions .eslintrc.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*.js text eol=lf
*.jsx text eol=lf
*.ts text eol=lf
*.mts text eol=lf
*.tsx text eol=lf
*.json text eol=lf
*.yml text eol=lf
Expand Down
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
directory: '/'
schedule:
interval: monthly
reviewers:
Expand All @@ -13,7 +13,7 @@ updates:
prefix-development: chore(deps-dev)

- package-ecosystem: npm
directory: "/"
directory: '/'
schedule:
interval: monthly
open-pull-requests-limit: 10
Expand Down
81 changes: 8 additions & 73 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@ name: CI

on:
push:
branches:
- main
pull_request:
schedule:
- cron: "0 0 1 * *"

jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm ci
- run: npm run lint

node_tests:
test:
name: Node ${{ matrix.node }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 10
Expand All @@ -37,67 +29,10 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: npm

- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v4
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci

- name: Run TypeScript tests
run: npm run test:typescript

- name: Run Node tests
run: npm run coverage:node

browser_tests:
name: Browser
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: true
matrix:
browser:
- chrome
- firefox
os:
- ubuntu-latest
- windows-latest

steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Install Node
uses: actions/setup-node@v4

- name: Install dependencies
run: npm ci

# Chrome
- uses: browser-actions/setup-chrome@latest
if: matrix.browser == 'chrome'

- name: Run tests on Chrome
if: matrix.browser == 'chrome'
run: |
npm run test:browser -- --browsers=ChromeHeadless
# Firefox
- uses: browser-actions/setup-chrome@latest
if: matrix.browser == 'firefox'
- run: npm ci
- run: npm run lint

- name: Run tests on Firefox
if: matrix.browser == 'firefox'
run: |
npm run test:browser -- --browsers=FirefoxHeadless
- name: Run tests
run: npm run test --ignore-scripts
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ nbproject
# IDEs & Text Editors
.idea
.sublime-*
.vscode/settings.json
.netbeans
nbproject

Expand Down
9 changes: 0 additions & 9 deletions .mocharc.yml

This file was deleted.

10 changes: 0 additions & 10 deletions .nycrc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
coverage/
test/specs/invalid/invalid.json
47 changes: 0 additions & 47 deletions .vscode/launch.json

This file was deleted.

5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
}
}
34 changes: 0 additions & 34 deletions .vscode/tasks.json

This file was deleted.

Loading

0 comments on commit 6f3926d

Please sign in to comment.