【问题标题】:Running jest from maven with frontend-maven-plugin使用 frontend-maven-plugin 从 maven 运行 jest
【发布时间】:2018-12-13 19:26:52
【问题描述】:

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>

【问题讨论】:

    标签: maven jestjs


    【解决方案1】:

    我们正在使用带有 jest 的 npm 进行测试,这是配置:

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

    如果测试不满足,构建将失败

    【讨论】:

    • Maven 构建一旦运行开玩笑测试就会挂起。知道为什么
    • @rogger2016 也许你的 npm 测试运行了一个监视会话,所以它没有返回,它只是等待?
    猜你喜欢
    • 2016-12-08
    • 1970-01-01
    • 1970-01-01
    • 2020-05-20
    • 2016-09-27
    • 1970-01-01
    • 2019-11-03
    • 1970-01-01
    • 2012-02-11
    相关资源
    最近更新 更多