Passed
Push — trunk ( fc18b0...3f698e )
by Christian
15:27 queued 15s
created

src/Administration/Resources/app/administration/jest.vue3.config.js   A

Complexity

Total Complexity 5
Complexity/F 2.5

Size

Lines of Code 93
Function Count 2

Duplication

Duplicated Lines 93
Ratio 100 %

Importance

Changes 0
Metric Value
wmc 5
eloc 57
mnd 3
bc 3
fnc 2
dl 93
loc 93
rs 10
bpm 1.5
cpm 2.5
noi 0
c 0
b 0
f 0

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
/**
2
 * @package admin
3
 */
4
5
// For a detailed explanation regarding each configuration property, visit:
6
// https://jestjs.io/docs/en/configuration.html
7 View Code Duplication
const { join, resolve } = require('path');
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8
9
process.env.PROJECT_ROOT = process.env.PROJECT_ROOT || process.env.INIT_CWD || '.';
10
process.env.ADMIN_PATH = process.env.ADMIN_PATH || __dirname;
11
process.env.TZ = process.env.TZ || 'UTC';
12
13
process.env.JEST_CACHE_DIR = process.env.JEST_CACHE_DIR ? `${process.env.JEST_CACHE_DIR}_vue3` : '<rootDir>.jestcache_vue3';
14
15
const isCi = (() => {
16
    return process.argv.some((arg) => arg === '--ci');
17
})();
18
19
if (isCi) {
20
    // eslint-disable-next-line no-console
21
    console.info('Run Jest in CI mode');
22
} else {
23
    // eslint-disable-next-line no-console
24
    console.info('Run Jest in local mode');
25
}
26
27
module.exports = {
28
    cacheDirectory: process.env.JEST_CACHE_DIR,
29
    preset: '@shopware-ag/jest-preset-sw6-admin',
30
    globals: {
31
        adminPath: process.env.ADMIN_PATH,
32
        projectRoot: process.env.PROJECT_ROOT,
33
    },
34
35
    globalTeardown: '<rootDir>test/globalTeardown.js',
36
37
    testRunner: 'jest-jasmine2',
38
39
    coverageDirectory: join(process.env.PROJECT_ROOT, '/build/artifacts/vue3/jest'),
40
41
    collectCoverageFrom: [
42
        'src/**/*.js',
43
        'src/**/*.ts',
44
        '!src/**/*.spec.js',
45
        '!src/**/*.spec.vue3.js',
46
    ],
47
48
    coverageReporters: [
49
        'text',
50
        'cobertura',
51
        'html-spa',
52
    ],
53
54
    setupFilesAfterEnv: [
55
        resolve(join(__dirname, '/test/_setup/prepare_vue3_environment.js')),
56
    ],
57
58
    transform: {
59
        // stringify svg imports
60
        '.*\\.(svg)$': '<rootDir>/test/transformer/svgStringifyTransformer.js',
61
    },
62
63
    transformIgnorePatterns: [
64
        '/node_modules/(?!(@shopware-ag/meteor-icon-kit|uuidv7|@vue/compat|other)/)',
65
    ],
66
67
    moduleNameMapper: {
68
        '^test(.*)$': '<rootDir>/test$1',
69
        '^\@shopware-ag\/admin-extension-sdk\/es\/(.*)': '<rootDir>/node_modules/@shopware-ag/admin-extension-sdk/umd/$1',
70
        '^lodash-es$': 'lodash',
71
        vue$: '@vue/compat/dist/vue.cjs.js',
72
    },
73
74
    reporters: isCi ? [
75
        [
76
            'jest-silent-reporter',
77
            {
78
                useDots: true,
79
                showWarnings: true,
80
                showPaths: true,
81
            },
82
        ],
83
        ['jest-junit', {
84
            suiteName: 'Shopware 6 Unit Tests',
85
            outputDirectory: join(process.env.PROJECT_ROOT, '/build/artifacts/jest'),
86
            outputName: 'administration.junit.xml',
87
        }],
88
    ] : [
89
        'default',
90
    ],
91
92
    testMatch: [
93
        '<rootDir>/src/**/*.spec.vue3.js',
94
    ],
95
96
    testEnvironmentOptions: {
97
        customExportConditions: ['node', 'node-addons'],
98
    },
99
};
100