jhnns / rewire

Easy monkey-patching for node.js unit tests
MIT License
3.08k stars 128 forks source link

SyntaxError when loading files using spread operator in object literals #133

Closed rbriank closed 6 years ago

rbriank commented 6 years ago

Any code which uses the spread operator in this way can't be loaded by rewire.

$ cat > test.js
const profile = {
  a: 1,
  b: 2
}

const other = {
  ...profile
}

$ node test.js
$

$ node -v
v8.9.3

$ npm i --save-dev rewire
+ rewire@3.0.2

$ node
> const rewire = require('rewire')
undefined
> const test = rewire('./test.js')
SyntaxError: ./test.js: Unexpected token (7:2)
  5 |
  6 | const other = {
> 7 |   ...profile
    |   ^
  8 | }
  9 |
rbriank commented 6 years ago

Apparently there is a fix in the pipe for this already: #128