Skip to content

Commit 0d85fec

Browse files
authored
Switch back to using the src alias, and import quasar's aliases (#9)
directly in the jest configuration using require-json5.
1 parent 055629b commit 0d85fec

32 files changed

+105
-96
lines changed

jest.config.js

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
1-
/* eslint-disable no-undef */
2-
3-
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
4-
const { pathsToModuleNameMapper } = require('ts-jest/utils')
5-
// In the following statement, replace `./tsconfig` with the path to your `tsconfig` file
6-
// which contains the path mapping (ie the `compilerOptions.paths` option):
7-
8-
const { compilerOptions } = require('./tsconfig')
9-
10-
1+
/* eslint-env node */
112

123
module.exports = {
134
preset: 'ts-jest',
145
testEnvironment: 'node',
156
globals: {
16-
"ts-jest": {
17-
"tsconfig": "tsconfig.json",
18-
"diagnostics": true
7+
'ts-jest': {
8+
'tsconfig': 'tsconfig.json',
9+
'diagnostics': true
1910
}
2011
},
21-
// A map from regular expressions to module names that allow to stub out resources with a single module
22-
// moduleNameMapper: {
23-
// '^@/(.*)$': '<rootDir>/src/$1',
24-
// },
25-
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths , { prefix: '<rootDir>/' } ),
26-
testRegex: "(/tests/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
12+
moduleNameMapper: {
13+
'^src/(.*)$': '<rootDir>/src/$1',
14+
'^app/(.*)$': '<rootDir>/$1',
15+
'^components/(.*)$': '<rootDir>/src/components/$1',
16+
'^layouts/(.*)$': '<rootDir>/src/layouts/$1',
17+
'^pages/(.*)$': '<rootDir>/src/pages/$1',
18+
'^assets/(.*)$': '<rootDir>/src/assets/$1',
19+
'^boot/(.*)$': '<rootDir>/src/boot/$1'
20+
},
21+
testRegex: '(/tests/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
2722
};

package-lock.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"eslint-config-prettier": "^8.1.0",
4545
"eslint-plugin-vue": "^7.0.0",
4646
"jest": "^27.2.2",
47+
"require-json5": "^1.1.0",
4748
"stylelint": "^13.13.1",
4849
"stylelint-config-prettier": "^8.0.2",
4950
"stylelint-config-recommended-scss": "^4.3.0",

quasar.conf.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ module.exports = configure(function (ctx) {
5353
}));
5454

5555
chain.plugin('nodePolyfills').use(NodePolyfillPlugin);
56-
/* allow paths to start with @/ */
57-
chain.resolve.alias.set('@', path.resolve(__dirname, './src'))
5856

5957
if (ctx.prod) {
6058
chain.plugin('copy-webpack')

src/APIRequests/renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This should more than likely be redirected at the backend rather
22
// than the renderer, unless we're going to go with the JWE route.
33
import axios from 'axios';
4-
import type { HTML, RendererResponse } from '@/typings/renderer';
4+
import type { HTML, RendererResponse } from 'src/typings/renderer';
55

66
export async function fetchProblem(url: string, formData: FormData, overrides: { [key: string]: string }) {
77
for (const key in overrides) {

src/boot/i18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { boot } from 'quasar/wrappers';
22
import { createI18n } from 'vue-i18n';
3-
import messages from '@/i18n';
3+
import messages from 'src/i18n';
44

55
const i18n = createI18n({
66
locale: 'en-US',

src/components/common/Problem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import { defineComponent, ref, watch, onMounted, nextTick } from 'vue';
3131
import type { SubmitButton } from 'src/typings/renderer';
3232
import { fetchProblem } from 'src/APIRequests/renderer';
33-
import { RENDER_URL } from '@/constants';
33+
import { RENDER_URL } from 'src/constants';
3434
import * as bootstrap from 'bootstrap';
3535
import type JQueryStatic from 'jquery';
3636
import JQuery from 'jquery';

src/components/instructor/ClasslistManagerComponents/AddUsersFromFile.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ import { parse } from 'papaparse';
9999
import { AxiosError } from 'axios';
100100
import { logger } from 'boot/logger';
101101
102-
import { useStore } from '@/store';
103-
import type { Dictionary, ResponseError } from '@/store/models';
104-
import { MergedUser, CourseUser, User, ParseableMergedUser } from '@/store/models/users';
102+
import { useStore } from 'src/store';
103+
import type { Dictionary, ResponseError } from 'src/store/models';
104+
import { MergedUser, CourseUser, User, ParseableMergedUser } from 'src/store/models/users';
105105
import { pick, fromPairs, values, invert, mapValues, clone, isUndefined,
106106
assign, filter } from 'lodash-es';
107107

src/components/instructor/ProblemSetsManager.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646

4747
<script lang="ts">
4848
import { defineComponent, computed, ref, Ref } from 'vue';
49-
import { useStore } from '@/store';
50-
import { ProblemSet, QuizDates } from '@/store/models/problem_sets';
51-
import { formatDate } from '@/common';
49+
import { useStore } from 'src/store';
50+
import { ProblemSet, QuizDates } from 'src/store/models/problem_sets';
51+
import { formatDate } from 'src/common';
5252
5353
export default defineComponent({
5454
name: 'ProblemSetsManager',

src/components/instructor/SetDetails/HomeworkSet.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ import { useQuasar } from 'quasar';
4343
import { cloneDeep } from 'lodash-es';
4444
4545
import DateTimeInput from 'src/components/common/DateTimeInput.vue';
46-
import { HomeworkSet } from '@/store/models/problem_sets';
47-
import { useStore } from '@/store';
46+
import { HomeworkSet } from 'src/store/models/problem_sets';
47+
import { useStore } from 'src/store';
4848
4949
export default defineComponent({
5050
components: { DateTimeInput },

0 commit comments

Comments
 (0)