Skip to content

Commit

Permalink
(chore): Update tooling to have aliases for tools and mocks folder
Browse files Browse the repository at this point in the history
  • Loading branch information
NethmiRodrigo committed Feb 11, 2025
1 parent 5e244cc commit 74efb75
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 14 deletions.
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module.exports = {
'@openmrs/esm-framework': '@openmrs/esm-framework/mock',
'^dexie$': require.resolve('dexie'),
'^lodash-es/(.*)$': 'lodash/$1',
'^@tools/(.*)$': path.resolve(__dirname, 'tools', '$1'),
'^__mocks__/(.*)$': path.resolve(__dirname, '__mocks__', '$1'),
'^lodash-es$': 'lodash',
'^react-i18next$': path.resolve(__dirname, '__mocks__', 'react-i18next.js'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react';
import userEvent from '@testing-library/user-event';
import { screen, waitFor } from '@testing-library/react';
import { type FetchResponse, openmrsFetch, showNotification } from '@openmrs/esm-framework';
import { mockSubscription } from '../../../../__mocks__/openconceptlab.mock';
import { renderWithSwr } from '../../../../tools/test-helpers';
import { mockSubscription } from '__mocks__/openconceptlab.mock';
import { renderWithSwr } from '@tools/test-helpers';
import { startImportWithSubscription } from './import.resource';
import Import from './import.component';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { screen, waitFor } from '@testing-library/react';
import { usePagination } from '@openmrs/esm-framework';
import { renderWithSwr } from '../../../../../tools/test-helpers';
import { mockImportItems, mockPreviousImports } from '../../../../../__mocks__/openconceptlab.mock';
import { renderWithSwr } from '@tools/test-helpers';
import { mockImportItems, mockPreviousImports } from '__mocks__/openconceptlab.mock';
import { getImportDetails } from './import-items.resource';
import ImportItems from './import-items.component';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { screen, waitFor } from '@testing-library/react';
import { formatDatetime } from '@openmrs/esm-framework';
import { renderWithSwr } from '../../../../../tools/test-helpers';
import { mockPreviousImports } from '../../../../../__mocks__/openconceptlab.mock';
import { renderWithSwr } from '@tools/test-helpers';
import { mockPreviousImports } from '__mocks__/openconceptlab.mock';
import ImportOverview from './import-overview.component';

describe('Import Overview component', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { screen, waitFor } from '@testing-library/react';
import { formatDatetime, openmrsFetch, usePagination } from '@openmrs/esm-framework';
import { renderWithSwr } from '../../../../tools/test-helpers';
import { mockPreviousImports } from '../../../../__mocks__/openconceptlab.mock';
import { renderWithSwr } from '@tools/test-helpers';
import { mockPreviousImports } from '__mocks__/openconceptlab.mock';
import PreviousImports from './previous-imports.component';

const mockOpenmrsFetch = openmrsFetch as jest.Mock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react';
import userEvent from '@testing-library/user-event';
import { screen, waitFor } from '@testing-library/react';
import { type FetchResponse, openmrsFetch, showNotification } from '@openmrs/esm-framework';
import { renderWithSwr } from '../../../../tools/test-helpers';
import { mockSubscription } from '../../../../__mocks__/openconceptlab.mock';
import { renderWithSwr } from '@tools/test-helpers';
import { mockSubscription } from '__mocks__/openconceptlab.mock';
import { deleteSubscription, updateSubscription } from './subscription.resource';
import Subscription from './subscription.component';

Expand Down
11 changes: 10 additions & 1 deletion packages/esm-admin-openconceptlab-app/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
module.exports = require('openmrs/default-webpack-config');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
const config = (module.exports = require('openmrs/default-webpack-config'));
config.overrides.resolve = {
extensions: ['.tsx', '.ts', '.jsx', '.js', '.scss', '.json'],
alias: {
'@tools': path.resolve(__dirname, 'tools/'),
},
};
module.exports = config;
11 changes: 10 additions & 1 deletion packages/esm-reports-app/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
module.exports = require('openmrs/default-webpack-config');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
const config = (module.exports = require('openmrs/default-webpack-config'));
config.overrides.resolve = {
extensions: ['.tsx', '.ts', '.jsx', '.js', '.scss', '.json'],
alias: {
'@tools': path.resolve(__dirname, 'tools/'),
},
};
module.exports = config;
11 changes: 10 additions & 1 deletion packages/esm-system-admin-app/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
module.exports = require('openmrs/default-webpack-config');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
const config = (module.exports = require('openmrs/default-webpack-config'));
config.overrides.resolve = {
extensions: ['.tsx', '.ts', '.jsx', '.js', '.scss', '.json'],
alias: {
'@tools': path.resolve(__dirname, 'tools/'),
},
};
module.exports = config;
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"target": "esnext"
"target": "esnext",
"paths": {
"__mocks__/*": ["./__mocks__/*"],
"@tools/*": ["./tools/*"],
}
}
}

0 comments on commit 74efb75

Please sign in to comment.