Skip to content

Commit

Permalink
chore: add tests and lint checks (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtsvetkov-splunk authored Dec 5, 2024
1 parent 224375e commit 6cc66d4
Show file tree
Hide file tree
Showing 11 changed files with 2,859 additions and 197 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ jobs:
name: Splunk_TA_Example
path: Splunk_TA_Example*.tar.gz

ui-checks:
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
working-directory: ui
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: 'npm'
cache-dependency-path: 'ui/package-lock.json'
node-version-file: 'ui/package.json'
- name: Install Dependencies
run: npm ci
- name: Code lint
run: npm run lint
- name: Unit tests
run: npm run test

splunk-appinspect-cli:
name: splunk-appinspect-cli ${{ matrix.tags }}
needs:
Expand Down
1 change: 1 addition & 0 deletions ui/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
/coverage/
3 changes: 1 addition & 2 deletions ui/babel.config.js → ui/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-env node */
export default {
module.exports = {
presets: [
[
"@splunk/babel-preset",
Expand Down
2 changes: 1 addition & 1 deletion ui/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import reactRefresh from "eslint-plugin-react-refresh";
import tseslint from "typescript-eslint";

export default tseslint.config(
{ ignores: ["dist"] },
{ ignores: ["dist", "coverage"] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.{ts,tsx}"],
Expand Down
42 changes: 42 additions & 0 deletions ui/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { Config } from "jest";

export default {
// Mock
clearMocks: true,
restoreMocks: true,
// env settings
testEnvironment: "jest-fixed-jsdom",
setupFilesAfterEnv: ["<rootDir>/tests/jest.setup.ts"],
// Coverage
collectCoverage: true,
collectCoverageFrom: ["src/**/*.{js,jsx,ts,tsx}"],
coveragePathIgnorePatterns: [
"/node_modules/",
/*
TYPES
*/
// *.d.ts files
"\\.d\\.ts$",
"/types/",
"\\.types\\.ts$",
],
coverageDirectory: "coverage",
testEnvironmentOptions: {
/**
* @note Opt-out from JSDOM using browser-style resolution
* for dependencies. This is simply incorrect, as JSDOM is
* not a browser, and loading browser-oriented bundles in
* Node.js will break things.
*
* Consider migrating to a more modern test runner if you
* don't want to deal with this.
*/
customExportConditions: [""],
},
errorOnDeprecated: true,
// moduleNameMapper: {
// // Force module uuid to resolve with the CJS entry point, because Jest does not support package.json.exports. See https://github.com/uuidjs/uuid/issues/451
// uuid: require.resolve("uuid"),
// "\\.(css)$": "<rootDir>/src/mocks/styleMock.js",
// },
} satisfies Config;
Loading

0 comments on commit 6cc66d4

Please sign in to comment.