cormacrelf / jest-csl

A library for testing CSL with Jest.
MIT License
2 stars 1 forks source link

What speaks against a global installation? And how to do it? #5

Open denismaier opened 5 years ago

denismaier commented 5 years ago

yarn add -D jest jest-csl leads to a local installation of jest-csl. Doing this for every csl style might be a bit cumbersome. Is there a reason why you don't suggest a global installation for this?

By the way, I've tried a global installation with yarn global add -D jest jest-csl but somehow I'm not able to run yarn test afterwards. I am getting the message /bin/sh: 1: jest: not found

cormacrelf commented 5 years ago

Local installations mean that CI tools can test it and be on the same version. You can add many styles to the same repo if you like, just add separate configs for each and then you can test each separately. Put a different scripts entry for each of the configurations, might be better.

I can’t help much with that error. Any number of things could be wrong, depending on the way you installed Node, Yarn etc. The jest invocation in the yarn script runner expects to find it in the PATH, which includes $DIR/node_modules/bin where DIR is where your package.json is found. Adding jest globally will not satisfy this, so it seems it isn’t even in your normal PATH.

denismaier commented 5 years ago

Ok. That sounds good. Could you give me a hint how such a multi-style test setup might look like?

cormacrelf commented 5 years ago

Basically follow the readme but do bits more than once. For each style called $STYLE you will need:

{
  "scripts": {
    "test": "jest --noStackTrace",
    "test-$STYLE": "jest --watchAll --noStackTrace test/$STYLE.test.js"
  }
}

Then run yarn test-my-first-style or yarn test-other-style as you wish. yarn test for all of them in one hit.

If it's a bit tedious matching styles to their respective directories in test, you could group them as styles/$STYLE/$STYLE.test.js styles/$STYLE/$STYLE.csl + styles/$STYLE/tests/*.yaml instead. It's quite flexible. (It might be harder for a non-techie to navigate the repo in that case, but maybe not too bad.)

denismaier commented 5 years ago

Thanks a lot. That really helps...