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

Commit 72289fd

Browse files
committed
throw if first argument is not cypress config
1 parent 6715584 commit 72289fd

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ const defaults = {
4343
module.exports = (config, userOptions = {}) => {
4444
log('received user options', userOptions)
4545

46+
if (!config || typeof config.isTextTerminal !== 'boolean') {
47+
throw new Error(`Cypress Browserify Preprocessor must be called with the Cypress config as its first argument. You passed: ${JSON.stringify(config, null, 2)}`)
48+
}
49+
50+
const options = Object.assign({}, defaults, userOptions)
51+
4652
return (filePath, util) => {
4753
log('get', filePath)
4854

test/index_spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ describe('browserify preprocessor', function () {
6666
it('receives user options and returns a preprocessor function', function () {
6767
expect(preprocessor(this.config, this.userOptions)).to.be.a('function')
6868
})
69+
70+
it('throws error if config is not the first argument', function () {
71+
expect(preprocessor).to.throw('must be called with the Cypress config')
72+
})
6973
})
7074

7175
describe('preprocessor function', function () {

0 commit comments

Comments
 (0)