maven - 使用 frontend-maven-plugin 从 maven 运行 jest
问题描述
jest 的文档似乎都假设我们熟悉整个 yarn/npm/node 生态系统(我是一个 java 人,所以不是那么多)。
我在pom.xml
运行 webpack 中有以下内容。我只是不知道如何扩展它,以便 mvn test 开玩笑地运行单元测试
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<installDirectory>target</installDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v10.11.0</nodeVersion>
<npmVersion>6.4.1</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>webpack build</id>
<goals>
<goal>webpack</goal>
</goals>
</execution>
<execution>
<id>test</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>test</phase>
<configuration>
<arguments>test</arguments>
<environmentVariables>
<CI>true</CI>
</environmentVariables>
</configuration>
</execution>
</executions>
</plugin>
解决方案
我们正在使用带有 jest 的 npm 进行测试,这是配置:
<execution>
<id>run tests</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>test</arguments>
</configuration>
</execution>
如果测试不满足,构建将失败
推荐阅读
- javascript - 在 Vue 中切换 MANY divs onclick 而不预先声明变量
- c# - C#并发队列使用
- javascript - 如何编写一个将数组内的对象作为输出返回的Javascript函数
- python-3.x - np.nanstd 在 python 中返回 inf 值
- cmake - 在CMake中对数字列表进行数字排序
- reactjs - 使用 React useState hook 设置多个状态值
- node.js - 如何将 Svelte 应用程序放入 docker 容器中?
- machine-learning - 如何在测试数据上使用 Pipeline 和 GridSearch 模型?
- spring - 在repository.save 后未加载Manytoone 对象-急切的获取不起作用
- python - 计算部分列表出现次数的最快方法