cypress-browserify-preprocessor icon indicating copy to clipboard operation
cypress-browserify-preprocessor copied to clipboard

Seems we cannot use custom tsify

Open bahmutov opened this issue 4 years ago • 3 comments
trafficstars

Cypress v6 @cypress/browserify-preprocessor 3.0.1

my settings specify tsify plugin

const browserify = require('@cypress/browserify-preprocessor')
module.exports = (on, config) => {
  const options = browserify.defaultOptions
  options.browserifyOptions.extensions.push('.ts')
  options.browserifyOptions.transform.push('browserify-istanbul')
  options.browserifyOptions.plugin.push('tsify')
  on('file:preprocessor', browserify(options))
}

Then I get the following message

Screen Shot 2021-01-19 at 5 33 40 PM

But if I also use typescript: require.resolve('typescript') option, then my tsify plugin is not used (./lib/simple_tsify is used instead)

bahmutov avatar Jan 19 '21 22:01 bahmutov

Reproducible example https://github.com/cypress-io/code-coverage/tree/try-tsify

  • clone
  • npm install
  • cd examples/unit-tests-ts
  • DEBUG=cypress:browserify npm run cy:open

bahmutov avatar Jan 19 '21 22:01 bahmutov

I need custom tsify to instrument the transpiled code. Something like this works for me from Node

// can we instrument typescript code using Istanbul?
const browserify = require('browserify');
// https://github.com/TypeStrong/tsify
const tsify = require('tsify');
// https://github.com/devongovett/browserify-istanbul
const istanbul = require('browserify-istanbul')

browserify()
  .add('main.ts')
  .plugin(tsify)
  .transform(istanbul)
  .bundle()
  .on('error', function (error) { console.error(error.toString()); })
  .pipe(process.stdout);

bahmutov avatar Jan 19 '21 22:01 bahmutov

@bahmutov Can u please provide a solution to this issue? Of all the work we did to replace testing framework from Jest and Selenium to Cypress last year, this is the only limitation we are stuck now. Thanks.

aslamj avatar May 19 '21 09:05 aslamj