Skip to content

Commit

Permalink
U/sgriffin/jest (#1277)
Browse files Browse the repository at this point in the history
* Implement tests with jest

* export function findTabStops

* Add Received tests using jest matcher

* add antispam tests

* add datetime tests

* implement GetHeaderList tests

* First pass on errors tests

* move matchers to subdir

* adjust cleanStack for jest

* better file name

* add xml tests

* remove grunt/qunit

* make command line and vs code error tests work at the same time

* Fix filename

* adjust stacks further for website runner

* don't fail on coverage (yet)

* Add linting

* clean up lint

* add some whitespace fixup lint

* remove lint todo

* convert jest config to typescript

* enable esModuleInterop

* enable allowSyntheticDefaultImports

* clean up scripts

* Tidy up webpack.config.js

* remove dead comment

* remove redundant strict checks

* remove more implied by strict

* slight script tweaks

* Enable no-inferrable-types

* remove dead comment
  • Loading branch information
stephenegriffin authored Oct 1, 2024
1 parent 9f78271 commit ddf828f
Show file tree
Hide file tree
Showing 61 changed files with 9,232 additions and 6,792 deletions.
29 changes: 8 additions & 21 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,17 @@ module.exports = {
},
"plugins": [
"@typescript-eslint",
"@stylistic/js",
"node"
],
"rules": {
"indent": [
"error",
4,
{
"SwitchCase": 1,
},
],
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
],
"indent": ["error", 4, { "SwitchCase": 1, },],
"linebreak-style": ["error", "windows"],
"quotes": ["error", "double"],
"semi": ["error", "always"],
"@stylistic/js/no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0, "maxBOF": 0 }],
"@stylistic/js/no-trailing-spaces": "error",
"@typescript-eslint/no-explicit-any": "off", // TODO: consider removing this
"@typescript-eslint/ban-ts-comment": "off", // TODO: consider removing this
"@typescript-eslint/no-inferrable-types": "off", // TODO: consider removing this
"@typescript-eslint/no-inferrable-types": "error",
}
};
5 changes: 2 additions & 3 deletions .github/workflows/qunit.yml → .github/workflows/jest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: QUnit MHA
name: Jest MHA

on:
workflow_dispatch:
Expand Down Expand Up @@ -29,5 +29,4 @@ jobs:
- name: NPM build, test
run: |
npm ci
npm run build --if-present
npm run test --if-present
npm test
26 changes: 0 additions & 26 deletions Gruntfile.js

This file was deleted.

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Here is a standalone Message Header Analyzer running the same backend code as th
Unit Tests
-----

<https://mha.azurewebsites.net/pages/unittests.html>
<https://mha.azurewebsites.net/Pages/test>

Mobile
-----
Expand Down Expand Up @@ -72,8 +72,9 @@ Unit Testing

- Start the dev server: `npm run dev-server`
- Run unit tests from command line: `npm run test`
- Run unit tests locally in browser: <https://localhost:44336/Pages/unittests.html>
- Changes made to source should live compile and reload page. Ctrl+R/refresh as needed.
- View test results here: <https://localhost:44336/Pages/test/>
- View code coverage here: <https://localhost:44336/Pages/coverage/lcov-report/>
- After changing source you will need to `npm run test` again.

Live site testing
-----
Expand Down
32 changes: 32 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type {Config} from "jest";
// https://github.com/jest-community/awesome-jest
const config: Config = {
testEnvironment: "jsdom",
transform: {
"^.+.tsx?$": ["ts-jest",{ diagnostics: { ignoreCodes: ["TS151001"] } }],
},
globals: {
"__AIKEY__": ""
},
collectCoverage: true,
collectCoverageFrom: ["./src/**"],
coverageDirectory: "./Pages/coverage",
coverageReporters: ["json", "lcov", "text", "clover"],
coverageThreshold: {
global: {
branches: 25,
functions: 20,
lines: 25,
statements: 25,
},
},
reporters: [
"default",
["jest-html-reporters", {
"publicPath": "./Pages/test",
"filename": "index.html"
}]
]
};

export default config;
23 changes: 0 additions & 23 deletions merge-dependabot.ps1

This file was deleted.

Loading

0 comments on commit ddf828f

Please sign in to comment.