Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Seems we cannot use custom tsify #62

Open
bahmutov opened this issue Jan 19, 2021 · 3 comments
Open

Seems we cannot use custom tsify #62

bahmutov opened this issue Jan 19, 2021 · 3 comments

Comments

@bahmutov
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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);

@aslamj
Copy link

aslamj commented May 19, 2021

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants