-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugins API - preprocessing with source file - electron/ chrome run #1654
Comments
By configuring the preprocessor in either of those ways, you're bypassing the default preprocessing and bundling that Cypress does. That means you can't use any features that aren't supported by the browser you're running the tests in. In this case, it looks like there's a commonjs Is there a reason you can't use the default preprocessor? |
@chrisbreiding yes. My requirement is to selectively pre-process some of the tests (not all). So instead of browserifying everything just to make it compatible with the browser, isn't any other way? If I trim the files down to tens, everything works fine. |
You need to browserify anything that's not compatible with the browser. There's no getting around that. You can certainly do that selectively, but it will require a little bit of logic. Something like: |
Sorry, that wasn't complete before I submitted it. const browserify = require('@cypress/browserify-preprocessor')
const watch = require('@cypress/watch-preprocessor')
module.exports = (on) => {
on('file:preprocessor', (file) => {
if (/* file doesn't need preprocessing */) {
return watch()(file)
} else {
return browserify()(file)
}
})
} |
@chrisbreiding watch()(file) resolves source filePath, which I mentioned already to be failing, for the reasons you explained. Ideally there should be a way to exit the callback without resolving anything, which would let the normal preprocessor kick through. |
Please see my above comment. The one above that had incomplete code. |
@chrisbreiding the watcher returns filePath (source file), which gets us back to square one. const filePath = file.filePath
// if shouldWatch is false, this is a one-time run, probably in CI
// so we don't need to watch
// since this function can get called multiple times with the same
// filePath, we return if we already have a cached watcher
// since we don't want or need to re-initiate a watcher for it
if (!file.shouldWatch || watchers[filePath]) {
return filePath
} |
If you need to resolve a different file path, you can do so like this: return watch()(file).then(() => '/desired/output/path') |
There's no output path given I start from an empty install. No output files have been processed regularly at that time. |
How are your files being processed in the case where you don't want them browserified? |
Nope. For the ones that does not need processing, they should flow into the default native pre-processor. |
What does it mean for those files to be 'processed regularly'? |
They get transpiled by the default preprocessor, outside the Plugins API, right? But I don't have this option with the current implementation. |
If that's the case, then why is there no output path? Also, can you explain why some files do not need to be or cannot to be processed? |
On the first install, you won't have an output directory eg Worth mentioning that outputPath will be created, if I don't use The business reason for selectively preprocessing files is the feature toggles concept I'm following. Given a project build with certain toggles in place, I need a way to decide which tests needs to be skipped (replace "it" with "xit"), provided the covered features aren't part of the build (toggled-off). |
I see. In that case, is it alright if they don't run instead of being skipped with
That way you're resolving a file that exists while skipping tests you don't want run. In |
This sounds like an elongated You could simply wrap |
@chrisbreiding my requirement is to still be able to run other "its" within the file, so this won't work. My only blocker is that it does it for all 140 files, instead of just 2-3 files which are actually subject to having certain |
|
Current behavior:
Not being able to run "cypress run" (default to electron), when preprocessing the source file.
Ending up in "Uncaught ReferenceError: require is not defined"
Desired behavior:
To be able to run it successfully.
Steps to reproduce:
same thing goes for
Versions
cypress@2.1.0, MacOs Sierra 10.12.6
The text was updated successfully, but these errors were encountered: