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

npm test causing SyntaxError #23

Closed
Cisplatin opened this issue Nov 17, 2017 · 3 comments
Closed

npm test causing SyntaxError #23

Cisplatin opened this issue Nov 17, 2017 · 3 comments

Comments

@Cisplatin
Copy link
Contributor

After running npm install --dev (which works fine), I run npm test and get the following:

~/Projects/solium-plugin-security (master) $ npm test

> solium-plugin-security@0.0.2 test /Users/Cisplatin/Projects/solium-plugin-security
> mocha --require should --reporter spec --recursive

npm /Users/Cisplatin/Projects/solium-plugin-security/test/index.js:18
		const { meta, rules } = SoliumSecurityPlugin;
		      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at /Users/Cisplatin/Projects/solium-plugin-security/node_modules/mocha/lib/mocha.js:231:27
    at Array.forEach (native)
    at Mocha.loadFiles (/Users/Cisplatin/Projects/solium-plugin-security/node_modules/mocha/lib/mocha.js:228:14)
    at Mocha.run (/Users/Cisplatin/Projects/solium-plugin-security/node_modules/mocha/lib/mocha.js:514:10)
    at Object.<anonymous> (/Users/Cisplatin/Projects/solium-plugin-security/node_modules/mocha/bin/_mocha:484:18)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:142:18)
    at node.js:939:3
npm ERR! Test failed.  See above for more details.

This is running node v5.9.0

@Cisplatin Cisplatin changed the title npm test causing SyntaxError: Unexpected token { npm test causing SyntaxError Nov 17, 2017
@Cisplatin
Copy link
Contributor Author

I updated node to v8.9.1, and now all the tests are failing, all with the same issue. Here's one of the tests:

  9) [RULE] enforce-placeholder-last: Acceptances
       should accept contracts with bad placeholder style:
     TypeError: Cannot read property 'meta' of undefined
      at node_modules/solium/lib/rules.js:192:31
      at Array.forEach (<anonymous>)
      at Object.load (node_modules/solium/lib/rules.js:190:23)
      at EventEmitter.lint (node_modules/solium/lib/solium.js:97:32)
      at badStyles.forEach.badStyle (test/enforce-placeholder-last.js:74:24)
      at Array.forEach (<anonymous>)
      at Context.<anonymous> (test/enforce-placeholder-last.js:72:13)

@duaraghav8
Copy link
Owner

Reproducing the discussed problem + solution here for others' reference:

Problem

normally, all plugins in solium are supposed to be installed separately by the dev.
exception is the security plugin solium-plugin-security - it comes installed as a local dependancy in solium (for convenience of user)
this plugin has solium installed as a dev dependancy (this is required bc solium is what will run the plugin's tests)

Now when you add new rules to the plugin in your dev environment & run the test with new configuration, solium (dev-dependancy) requires the plugin. But it doesn't require this plugin that you're working on. Instead it requires the one installed inside it as local dep.

So right now what you did was to remove all plugin modules within solium's reach and make your modified plugin globally available so Solium requires the modified one.
Apologies for this convoluted mess -.-", feel free to clarify anything you don't understand

Solution

Clone this repo and download all deps npm i --dev
Be in the plugin's root dir (where you ran npm test)

  • cd node_modules/solium
  • npm uninstall --save solium-plugin-security
  • cd ../.. (back to root dir)
  • npm uninstall --save solium-plugin-security
  • npm link (or if this doesn't work) npm link solium-plugin-security
  • npm test

(You need to do the above only once for every new copy you download)

Bear with this for a while, I'll fix it very soon

@duaraghav8
Copy link
Owner

Fixed. Now you can set up dev env easily:

git clone ...
cd solium-plugin-security
npm i --dev
npm link / npm link solium-plugin-security
npm test
npm unlink (optional)

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

2 participants