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

TypeError: Cannot assign to read only property 'length' #149

Open
simaQ opened this Issue Jan 6, 2016 · 4 comments

Comments

Projects
None yet
4 participants
@simaQ

simaQ commented Jan 6, 2016

Chrome Version: 47.0.2526.106 (64-bit)

throw this error.

Caused by Assertion.prototype.length method.

@simaQ simaQ changed the title from TypeError: Cannot assign to read only property to TypeError: Cannot assign to read only property 'length' Jan 7, 2016

@chrisbwall

This comment has been minimized.

chrisbwall commented Aug 10, 2016

+1: having the same issue any time I pass anything that isn't a strict primitive to expect()

@zwhitchcox

This comment has been minimized.

zwhitchcox commented Mar 6, 2017

+1 same

@larsgw

This comment has been minimized.

larsgw commented Jul 29, 2017

+1: Same issue, but for all assertions

@larsgw

This comment has been minimized.

larsgw commented Apr 29, 2018

Seems to be caused by 'use strict'.


A possible workaround for Babel/Babelify usage is including expect.js on its own, without Babel or Babelify parsing, as that adds a 'use strict'. This can be done, in the case of Babelify, by making a separate bundle without babelify specifically for expect.js, and then including both in your page:

browserify()
  .require('expect.js')
  .bundle()
  .pipe(fs.createWriteStream(path.join(__dirname, '../build/expect.js')))

browserify()
  .exclude(['expect.js'])
  .add('./test/*.js')
  .transform(babelify)
  .bundle()
  .pipe(fs.createWriteStream(path.join(__dirname, '../build/test.js')))

I can't get the Babelify ignore option to work (see babel/babelify#265), but that is probably a good option too.

larsgw added a commit to larsgw/citation.js that referenced this issue Apr 30, 2018

[site:test] Fix browser tests again
expect.js doesn't play nicely with Babel, so it
shouldn't be transformed by Babelify.^1 Note that
the ignore option in Babelify is buggy ^2, so
this might not work on your end.

^1 Automattic/expect.js#149
^2 babel/babelify#265

larsgw added a commit to larsgw/citation.js that referenced this issue May 2, 2018

[test:input] Set up HTTP request mocking (#136)
* [site:test] Fix browser tests again

expect.js doesn't play nicely with Babel, so it
shouldn't be transformed by Babelify.^1 Note that
the ignore option in Babelify is buggy ^2, so
this might not work on your end.

^1 Automattic/expect.js#149
^2 babel/babelify#265

* [test:input] Set up HTTP request mocking

Set up proper HTTP request mocking by mocking
exports with mock-require. Not possible in the
browser, but it wasn't before, so this counts
as an improvement.

Previously done by nock, but this didn't work for
requests made through sync-request, as that
spawns a child process over which nock has no
control.

See #68
See 509d911
Close #134

* [test:input] Increase coverage of input plugins

See #123 

* [package] Add non-npm patch to dependencies

See babel/babelify#267
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment