diff --git a/lib/__tests__/getData.test.js b/lib/__tests__/getData.test.js index f1d6c7c..34060ce 100644 --- a/lib/__tests__/getData.test.js +++ b/lib/__tests__/getData.test.js @@ -117,3 +117,22 @@ it('returns parsed config and report contents when a custom coverage directory i }, }) }) + +it('resolves as current directory', async () => { + jest.mock( + '../jest.config.js', + () => ({ + coverageThreshold, + coverageDirectory: '/custom/coverage/directory', + }), + { virtual: true }, + ) + + await getData(configPath) + + expect(fs.readFileSync).toHaveBeenCalledTimes(1) + expect(fs.readFileSync).toHaveBeenCalledWith( + `/workingDir/custom/coverage/directory/coverage-summary.json`, + 'utf8', + ) +}) diff --git a/lib/getData.js b/lib/getData.js index 2c1b94a..e8f7d61 100644 --- a/lib/getData.js +++ b/lib/getData.js @@ -9,7 +9,7 @@ const getData = async configPath => { } = typeof config === 'function' ? await config() : config const reportPath = path.resolve( path.dirname(configPath), - coverageDirectory, + coverageDirectory.replace('', '.'), 'coverage-summary.json', ) const { total: coverages } = JSON.parse(fs.readFileSync(reportPath, 'utf8'))