Skip to content

Commit

Permalink
Update esbuild-istanbul.js
Browse files Browse the repository at this point in the history
  • Loading branch information
thednp committed Apr 27, 2022
1 parent 0c3b0fe commit 8994e5f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cypress/plugins/esbuild-istanbul.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const debug = require('debug')('istanbul-lib-instrument')
// import Cypress settings
const { env: { sourceFolder } } = require('../../cypress.json');
const [name] = process.cwd().split(/[\\|\/]/).slice(-1);
const sourcePath = sourceFolder.replace(/\//,'\\');
const sourcePath = sourceFolder.replace(/\\/,'\/');

const sourceFilter = `\\${name}\\${sourcePath}`;
const sourceFilter = `${name}/${sourcePath}`;

/**
* @typedef {import('istanbul-lib-instrument').InstrumenterOptions} InstrumenterOptions
Expand All @@ -33,11 +33,12 @@ const instrumenter = createInstrumenter({
const esbuildPluginIstanbul = () => ({
name: 'istanbul',
setup(build) {
build.onLoad({filter: /\// },
build.onLoad({filter: /\.(js|jsx|ts|tsx)$/ },
async ({ path }) => {
const contents = String(readFileSync(path, 'utf8'));

if (!path.includes(sourceFilter)) {
// if (!path.includes(sourceFilter)) {
if (!sourceFilter.split(/\\|\//).every((word) => path.includes(word))) {
return { contents };
}
debug('instrumenting %s for output coverage', path);
Expand Down

0 comments on commit 8994e5f

Please sign in to comment.