Skip to content

Commit

Permalink
Merge pull request #29 from Mearman/develop
Browse files Browse the repository at this point in the history
add initial unit tests
  • Loading branch information
sywhb authored Mar 6, 2023
2 parents 7813735 + a3a7db6 commit d27c8e5
Show file tree
Hide file tree
Showing 9 changed files with 7,282 additions and 9,832 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# name: Node.js CI
# https://medium.com/swlh/jest-and-github-actions-eaf3eaf2427d
name: Node.js CI

on:
push:
branches: [ master, main, develop ]
pull_request:
branches: [ master, main, develop ]

jobs:
build:
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
node-version: [ 14.x, 16.x, 18.x, 19.x ]
max-parallel: 24
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm ci || npm install
# before the first 'run' each "run" is a script from your project:
# - run: npm run prettier
# - run: npm run linter
- run: npm run test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ data.json

# Exclude macOS Finder (System Explorer) View States
.DS_Store

coverage/

test-report.xml
11 changes: 11 additions & 0 deletions .run/All Tests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="All Tests" type="JavaScriptTestRunnerJest" nameIsGenerated="true">
<node-interpreter value="project" />
<node-options value="" />
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
<working-dir value="$PROJECT_DIR$" />
<envs />
<scope-kind value="ALL" />
<method v="2" />
</configuration>
</component>
27 changes: 27 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
// The test environment that Jest will use
testEnvironment: "node",

// The root directory for Jest tests
roots: ["<rootDir>/src"],

// The file extensions Jest will look for
moduleFileExtensions: ["ts", "js"],

// The test regex pattern to match test files
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",

// The module name mapper to resolve module paths
moduleNameMapper: {
"^obsidian$": "<rootDir>/src/__mocks__/obsidian.ts",
},

// The transform config for TypeScript files
transform: {
"^.+\\.tsx?$": "ts-jest",
},

// The coverage report config
collectCoverage: true,
coverageDirectory: "<rootDir>/coverage",
};
Loading

0 comments on commit d27c8e5

Please sign in to comment.