diff --git a/README.md b/README.md index 41fa6fd..ba05fa2 100644 --- a/README.md +++ b/README.md @@ -63,15 +63,59 @@ Then add `__tests__` to `sources` in your `bsconfig.json`: ```js "sources": [ { - "dir": "src" + "dir": "app", + "subdirs": true }, { "dir": "__tests__", - "type": "dev" + "type": "dev", + "subdirs": true } ] ``` +Then your project structure would look like this: + +``` +src/ +├── MyComponent.re +__tests__/ +├── MyComponent_test.re +README.md + + +(NOTE: no .re files in the root of src, if you put them there they will not be built) +``` + +### For Create React App + + +> **⚠️ WARNING: ⚠️** The following You run the danger of having your test files be included in your production bundle if you (by acident) reference them anywhere in your code. Otherwise they should be shaken out by Webpack or whatever bundler you're using. +> +> **However, we strongly recomend to instead have two distinctly seperate folders for tests and application code** this allows the compiler to enforce that development-only files don't get built with production ones (in this case tests). + + +Create React App requires your tests to be in the `src` folder and encourages you tests next to their testing files. You _can_ do this with the following: `bsconfig.json` + +```js +"sources": [ + { + "dir": "src", + "subdirs": true + } +] +``` + +Then you would write put your tests in a folder like this: + +``` +src/ +├── MyComponent.re +├── __tests__ +│   ├── MyComponent_test.re +README.md +``` + ## Usage Put tests in a `__tests__` directory and use the suffix `*test.ml`/`*test.re` (Make sure to use valid module names. e.g. `_test.re` is valid while `.test.re` is not). When compiled they will be put in a `__tests__` directory under `lib`, with a `*test.js` suffix, ready to be picked up when you run `jest`. If you're not already familiar with [Jest](https://github.com/facebook/jest), see [the Jest documentation](https://facebook.github.io/jest/).