From 8994e5fd9c419bf4f4126b53ec53a170d36d8dcb Mon Sep 17 00:00:00 2001 From: thednp Date: Wed, 27 Apr 2022 15:29:46 +0300 Subject: [PATCH] Update esbuild-istanbul.js --- cypress/plugins/esbuild-istanbul.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cypress/plugins/esbuild-istanbul.js b/cypress/plugins/esbuild-istanbul.js index 5aa2093..5ca989c 100644 --- a/cypress/plugins/esbuild-istanbul.js +++ b/cypress/plugins/esbuild-istanbul.js @@ -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 @@ -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);