詹金斯(Jenkins)开玩笑的未知报道

时间:2018-12-19 06:22:40

标签: javascript jenkins jenkins-pipeline jestjs

当我在本地计算机上运行package.json中存在的笑话测试脚本时,测试将运行并按预期提供代码覆盖范围。

但是当从jennkins执行相同的脚本时,运行测试但覆盖率显示 结果为“未知”,如下所示:

20:58:23 =============================== Coverage summary ===============================
20:58:23 Statements   : Unknown% ( 0/0 )
20:58:23 Branches     : Unknown% ( 0/0 )
20:58:23 Functions    : Unknown% ( 0/0 )
20:58:23 Lines        : Unknown% ( 0/0 )
20:58:23 ================================================================================
20:58:23 Test Suites: 15 passed, 15 total
20:58:23 Tests:       37 passed, 37 total
20:58:23 Snapshots:   0 total
20:58:23 Time:        9.106s
20:58:23 Ran all test suites.

下面是我最喜欢的配置文件:

module.exports = {
    verbose: true,
    globals: {
        'ts-jest': {
            tsConfigFile: 'tsconfig.json'
        }
    },
    moduleFileExtensions: [
        'ts',
        'js'
    ],
    transform: {
        '^.+\\.(ts|tsx)$': 'ts-jest'
    },
    testMatch: [
        '**/__tests__/**/*.(ts|js)',
        '**/src/**/*.spec.(ts|js)'
    ],
    testEnvironment: 'node',
    coveragePathIgnorePatterns: [
        '/node_modules/',
        '/coverage/',
        '/support/cacerts/',
        '/support/certs/',
        '/dist/',
        '/jenkins/',
        '/config/',
        '/logs/'
    ],
    collectCoverage: true,
    coverageReporters: [
        'cobertura',
        'html'
    ],
    collectCoverageFrom: [
        '**/src/**/*.{ts,js}',
        '!**/src/**/*.spec.{ts,js}',
        '!**/node_modules/**'
    ],
    coverageDirectory: "<rootDir>/coverage",
    coverageThreshold: {
        'global': {
            'branches': 60,
            'functions': 60,
            'lines': 60,
            'statements': 80
        }
    },
    moduleFileExtensions: [
        'ts',
        'js'
    ]
};

0 个答案:

没有答案