refactor: Update jest.config.json files with testPathIgnorePatterns

The jest.config.json files in the Model, Probe, Common, Copilot, CommonUI, Ingestor, IsolatedVM, TestServer, and CommonServer directories have been updated. The "testPathIgnorePatterns" property has been added to each file, excluding the "node_modules" and "dist" directories from test path matching. This change improves test performance and ensures that unnecessary files are not included in the test coverage.
This commit is contained in:
Simon Larsen 2024-06-11 14:52:55 +01:00
parent c53b14f88f
commit dfb7f2320c
No known key found for this signature in database
GPG key ID: 96C5DCA24769DBCA
14 changed files with 101 additions and 49 deletions

View file

@ -1,5 +1,10 @@
{
"preset": "ts-jest",
"preset": "ts-jest",
"testPathIgnorePatterns": [
"node_modules",
"dist"
],
"verbose": true,
"globals": {
"ts-jest": {

View file

@ -1,13 +1,12 @@
import Execute from '../Execute';
import CodeRepositoryFile from './CodeRepositoryFile';
import Dictionary from 'Common/Types/Dictionary';
export default class CodeRepositoryUtil {
public static async getGitCommitHashForFile(data: {
repoPath: string,
filePath: string
}
): Promise<string> {
repoPath: string;
filePath: string;
}): Promise<string> {
const { repoPath, filePath } = data;
return await Execute.executeCommand(
@ -16,16 +15,15 @@ export default class CodeRepositoryUtil {
}
public static async getFilesInDirectory(data: {
directoryPath: string,
repoPath: string
directoryPath: string;
repoPath: string;
}): Promise<{
files: Array<CodeRepositoryFile>;
files: Dictionary<CodeRepositoryFile>;
subDirectories: Array<string>;
}> {
const { directoryPath, repoPath } = data;
const files: Array<CodeRepositoryFile> = [];
const files: Dictionary<CodeRepositoryFile> = {};
const output: string = await Execute.executeCommand(
`ls ${directoryPath}`
);
@ -41,7 +39,7 @@ export default class CodeRepositoryUtil {
const isDirectory: boolean = (
await Execute.executeCommand(
`file ${directoryPath}/${fileName}`
`file "${directoryPath}/${fileName}"`
)
).includes('directory');
@ -53,15 +51,15 @@ export default class CodeRepositoryUtil {
const filePath: string = `${directoryPath}/${fileName}`;
const gitCommitHash: string = await this.getGitCommitHashForFile({
filePath,
repoPath
});
repoPath,
});
const fileExtension: string = fileName.split('.').pop() || '';
files.push({
files[filePath] = {
filePath,
gitCommitHash,
fileExtension,
fileName,
});
};
}
return {
@ -71,25 +69,30 @@ export default class CodeRepositoryUtil {
}
public static async getFilesInDirectoryRecursive(data: {
repoPath: string,
directoryPath: string
}): Promise<Array<CodeRepositoryFile>> {
const files: Array<CodeRepositoryFile> = [];
repoPath: string;
directoryPath: string;
}): Promise<Dictionary<CodeRepositoryFile>> {
let files: Dictionary<CodeRepositoryFile> = {};
const { files: filesInDirectory, subDirectories } =
await this.getFilesInDirectory({
directoryPath: data.directoryPath,
repoPath: data.repoPath
repoPath: data.repoPath,
});
files.push(...filesInDirectory);
files = {
...files,
...filesInDirectory,
};
for (const subDirectory of subDirectories) {
files.push(
files = {
...files,
...(await this.getFilesInDirectoryRecursive({
repoPath: data.repoPath,
directoryPath: subDirectory
}))
);
directoryPath: subDirectory,
})),
};
}
return files;

View file

@ -1,5 +1,10 @@
{
"preset": "ts-jest",
"preset": "ts-jest",
"testPathIgnorePatterns": [
"node_modules",
"dist"
],
"verbose": true,
"globals": {
"ts-jest": {

View file

@ -1,5 +1,10 @@
{
"preset": "ts-jest",
"preset": "ts-jest",
"testPathIgnorePatterns": [
"node_modules",
"dist"
],
"verbose": true,
"globals": {
"ts-jest": {

View file

@ -78,12 +78,12 @@
"dependencies": {
"@types/crypto-js": "^4.2.2",
"@types/uuid": "^8.3.4",
"axios": "^1.6.8",
"axios": "^1.7.1",
"crypto-js": "^4.1.1",
"json5": "^2.2.3",
"moment": "^2.30.1",
"moment-timezone": "^0.5.45",
"posthog-js": "^1.130.2",
"posthog-js": "^1.131.4",
"reflect-metadata": "^0.2.2",
"slugify": "^1.6.5",
"typeorm": "^0.3.20",

View file

@ -165,7 +165,9 @@ describe('DuplicateModel', () => {
await waitFor(() => {
return expect(
require('../../Utils/Navigation').navigate
).toBeCalledWith(new Route('/done/foobar'));
).toBeCalledWith(new Route('/done/foobar'), {
forceNavigate: true,
});
});
});
it('closes confirmation dialog when close button is clicked', () => {

View file

@ -1,28 +1,30 @@
import { GetLocalRepositoryPath } from './Config';
import CodeRepositoryUtil from './Utils/CodeRepository';
import Dictionary from 'Common/Types/Dictionary';
import { PromiseVoidFunction } from 'Common/Types/FunctionTypes';
import CodeRepositoryCommonServerUtil from 'CommonServer/Utils/CodeRepository/CodeRepository';
import CodeRepositoryFile from 'CommonServer/Utils/CodeRepository/CodeRepositoryFile';
import logger from 'CommonServer/Utils/Logger';
import CodeRepository from 'Model/Models/CodeRepository';
import dotenv from 'dotenv';
import CodeRepositoryFile from 'CommonServer/Utils/CodeRepository/CodeRepositoryFile'
import CodeRepositoryCommonServerUtil from 'CommonServer/Utils/CodeRepository/CodeRepository';
import { GetLocalRepositoryPath } from './Config';
dotenv.config();
logger.info('OneUptime Copilot is started...');
logger.info('OneUptime Copilot is starting...');
const init: PromiseVoidFunction = async (): Promise<void> => {
const codeRepository: CodeRepository =
await CodeRepositoryUtil.getCodeRepository();
logger.info(`Code Repository found: ${codeRepository.name}`);
const allFiles: Array<CodeRepositoryFile> = await CodeRepositoryCommonServerUtil.getFilesInDirectoryRecursive({
repoPath: GetLocalRepositoryPath(),
directoryPath: GetLocalRepositoryPath()
});
const allFiles: Dictionary<CodeRepositoryFile> =
await CodeRepositoryCommonServerUtil.getFilesInDirectoryRecursive({
repoPath: GetLocalRepositoryPath(),
directoryPath: GetLocalRepositoryPath(),
});
logger.info(`All files found: ${allFiles.length}`);
logger.info(`All files found: ${Object.keys(allFiles).length}`);
};
init()

View file

@ -1,5 +1,10 @@
{
"preset": "ts-jest",
"preset": "ts-jest",
"testPathIgnorePatterns": [
"node_modules",
"dist"
],
"verbose": true,
"globals": {
"ts-jest": {

View file

@ -1,5 +1,10 @@
{
"preset": "ts-jest",
"preset": "ts-jest",
"testPathIgnorePatterns": [
"node_modules",
"dist"
],
"verbose": true,
"globals": {
"ts-jest": {

View file

@ -1,5 +1,10 @@
{
"preset": "ts-jest",
"preset": "ts-jest",
"testPathIgnorePatterns": [
"node_modules",
"dist"
],
"verbose": true,
"globals": {
"ts-jest": {

View file

@ -1,5 +1,10 @@
{
"preset": "ts-jest",
"preset": "ts-jest",
"testPathIgnorePatterns": [
"node_modules",
"dist"
],
"verbose": true,
"globals": {
"ts-jest": {

View file

@ -1,5 +1,10 @@
{
"preset": "ts-jest",
"preset": "ts-jest",
"testPathIgnorePatterns": [
"node_modules",
"dist"
],
"verbose": true,
"globals": {
"ts-jest": {

View file

@ -1,5 +1,10 @@
{
"preset": "ts-jest",
"preset": "ts-jest",
"testPathIgnorePatterns": [
"node_modules",
"dist"
],
"verbose": true,
"globals": {
"ts-jest": {

View file

@ -43,8 +43,8 @@
"prerun": "bash configure.sh",
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js",
"uninstall": "bash uninstall.sh",
"lint": "ejslint **/*.ejs && eslint '**/*.ts*' -c .eslintrc.json --ignore-path .eslintignore ",
"fix-lint": " node --max_old_space_size=18192 ./node_modules/.bin/eslint '**/*.ts*' -c .eslintrc.json --ignore-path .eslintignore --fix --cache",
"lint": "ejslint **/*.ejs && eslint '**/*.{ts,tsx,json}' -c .eslintrc.json --ignore-path .eslintignore ",
"fix-lint": " node --max_old_space_size=18192 ./node_modules/.bin/eslint '**/*.{ts,tsx,json}' -c .eslintrc.json --ignore-path .eslintignore --fix --cache",
"fix": "npm run fix-lint",
"status-check": "bash ./Tests/Scripts/status-check.sh $npm_config_services",
"start": "export $(grep -v '^#' config.env | xargs) && docker compose up --remove-orphans -d $npm_config_services && npm run status-check",