代码之家  ›  专栏  ›  技术社区  ›  Don Hosek

使用前端maven插件从maven运行jest

  •  1
  • Don Hosek  · 技术社区  · 6 年前

    JOST的文档似乎都假设我们熟悉整个纱线/NPM/节点生态系统(我是爪哇人,所以不是那么多)。

    我有以下内容 pom.xml 用于运行Webpack。我只是不知道如何扩展它,以便MVN测试可以开玩笑地运行单元测试。

            <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>
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   Vizz85    6 年前

    我们使用NPM和JEST进行测试,这是配置:

    <execution>
        <id>run tests</id>
            <goals>
                <goal>npm</goal>
            </goals>
    
            <configuration>
                <arguments>test</arguments>
            </configuration>
    </execution>
    

    如果测试不满足,则生成将失败