Skip to content
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
Open

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

simaQ opened this issue Jan 6, 2016 · 4 comments

Comments

@simaQ
Copy link

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 TypeError: Cannot assign to read only property TypeError: Cannot assign to read only property 'length' Jan 7, 2016
@chrisbwall
Copy link

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

@zwhitchcox
Copy link

+1 same

@larsgw
Copy link

larsgw commented Jul 29, 2017

+1: Same issue, but for all assertions

@larsgw
Copy link

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
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
* [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
larsgw added a commit to citation-js/citation-js that referenced this issue Nov 24, 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

* [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 509d911836c7cb7adbc57440ce21a703308e01ff
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants