Electrode:将Jest测试文件保留在构建版本的/ lib之外

时间:2018-10-03 14:47:38

标签: jestjs babel walmart-electrode

如何将*.spec.js**.test.js*文件保留在/lib目录之外?

我觉得也许我错过了一些愚蠢的东西来设置Jest测试。我将测试放在the docs indicate之类的/src中,这是Jest测试的典型方法,但是进行构建会将测试文件复制到/lib目录中。

我一直在寻找重写此行为的方法,但是electrode-archetype-react-app/arch-clap.js中的这一点似乎阻止了对此的任何配置。

"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}` ) 
}

我制作了一个演示应用程序来说明这一点。

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

切换到适当的分支

git checkout electrode-jest-docs-issue

构建项目

yarn install && yarn cleanBuild

检查/ lib中的测试/规格文件

yarn hasLibTest

1 个答案:

答案 0 :(得分:0)

结果证明Electrode小组认为这是一个错误。我提交了一份PR,以解决已被合并和发布的问题。

如果包含electrode-archetype-react-app ^5.4.14,则应防止测试文件最终出现在/lib目录中。

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