Electrode: Keeping Jest test files out of /lib on build

238 views Asked by At

How do I keep the *.spec.js* and *.test.js* files out of the /lib directory?

I feel like maybe I missed something really dumb setting up Jest tests. I've put the tests in the /src like the docs indicate and is typical for Jest testing, but doing a build copies the test files to the /lib directory.

I've looked for ways to override this behavior, but it seems like this bit in the electrode-archetype-react-app/arch-clap.js prevents any config around this.

"build-lib:client": { 
    desc: false, 
    dep: [
        ".clean.lib:client", 
        ".mk.lib.client.dir", 
        ".build.client.babelrc"
    ], 
    task: mkCmd(`babel`, 
                `--source-maps=inline 
                   --copy-files 
                   --out-dir ${AppMode.lib.client}`, 
                `${AppMode.src.client}` ) 
}

I've made a little demo app to illustrate this.

https://github.com/snekse/electrode-jest-build-config-example

Switch to the proper branch

git checkout electrode-jest-docs-issue

Build the project

yarn install && yarn cleanBuild

Check for test/spec files in /lib

yarn hasLibTest
1

There are 1 answers

0
Snekse On BEST ANSWER

Turns out the Electrode team felt this was a bug. I submitted a PR to address the issue which has already been merged and published.

If you include electrode-archetype-react-app ^5.4.14, it should prevent the test files from ending up in your /lib directory.

https://github.com/electrode-io/electrode/pull/998