Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate unit tests to jest #162

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*!
* Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: MIT
*/

module.exports = {
extends: [
Expand All @@ -6,14 +10,25 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
],
plugins: ['@typescript-eslint'],

rules: {
"@typescript-eslint/return-await": 'off',
"@typescript-eslint/no-inferrable-types": 'warn',
"@typescript-eslint/no-explicit-any": 'warn',
'@typescript-eslint/no-explicit-any': 'off',
'no-console': 'warn',
'prefer-const': 'warn',
'no-useless-escape': 'warn'
'@typescript-eslint/no-unused-vars': [
'warn',
{
caughtErrors: 'none',
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true,
},
],
},
ignorePatterns: ['*.js', '*.d.ts', 'node_modules/'],
}
ignorePatterns: ['*.js', '*.d.ts', 'node_modules/', 'src/tests/yaml-strings', 'src/tests/json-strings'],
}

10 changes: 6 additions & 4 deletions .github/workflows/compile-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ name: compile-lint-test

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
# To avoid compatibility problems, pin the CI node.js version to node version used by VSCode Electron
# so integration testing will not rely on a later version of node than exists in the default VS Code execution env.
# Full table with details here: https://github.com/ewanharris/vscode-versions
node-version: [20.x]

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
node_modules
out
coverage
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lint-staged
4 changes: 4 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*.{js,yml,json,md}": "prettier --write",
"*.ts": ["eslint --fix", "prettier --write"]
}
3 changes: 0 additions & 3 deletions .mocharc.yml

This file was deleted.

9 changes: 9 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "http://json.schemastore.org/prettierrc",
"tabWidth": 2,
"trailingComma": "all",
"semi": false,
"useTabs": false,
"singleQuote": true,
"printWidth": 120
}
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [['@babel/preset-env', { targets: { node: 'current' } }]],
}
29 changes: 29 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*!
* Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: MIT
*/

/** @type {import('ts-jest').JestConfigWithTsJest} */

const transformCodeInPackages = []

module.exports = {
preset: 'ts-jest',
testMatch: ['**/src/**/?(*.)+(spec|test).ts'],

coverageReporters: ['cobertura', 'html', 'text'],
collectCoverageFrom: ['src/**/*.ts'],
coveragePathIgnorePatterns: ['^.*/scripts/.*$', '^.*/schema/.*$', '^.*/tests/.*$', 'interface.ts'],
transformIgnorePatterns: [`<rootDir>/node_modules/(?!${transformCodeInPackages.join('|')}).+\\.js$`],
transform: {
'^.+\\.(ts|tsx)?$': 'ts-jest',
'^.+\\.(js|jsx)$': [
'babel-jest',
{
presets: ['@babel/preset-env'],
plugins: [['@babel/transform-runtime']],
},
],
},
clearMocks: true,
}
Loading