reactjs - 从Powershell在Appveyor上运行Jest测试

标签 reactjs powershell jestjs appveyor react-create-app

我正在尝试在Appveyor上运行我的Jest测试。我正在将asp.net核心模板用于React应用程序(使用create-react-app)。当我在本地运行测试(使用npm run test)时,测试运行良好,我看到PASS src\App.test.js以及已通过的测试的概要。

但是,在Appveyor中,控制台抛出错误,导致构建失败。错误消息是PASS src\App.test.js。因此,尽管它似乎实际上已经过去了,但它似乎以某种方式从运行中发出了一个错误。我检查了,$LASTEXITCODE-1
App.Test.js
it('Runs tests', () => { expect(true).toBeTruthy(); });
Appveyor.yml
test_script: - ps: .\build\appveyor\js-tests.ps1
。\ build \ appveyor \ js-tests.ps1
($env:CI = $true) -and (npm run test)
我正在设置CI环境,因为这会阻止测试使用“监视”。 js-tests脚本还对文件位置进行了排序,并做了一些日志记录等其他工作,但是我不认为这与通过测试返回消息有关。

最佳答案

Npm有时会将正常输出写入stdErr,AppVeyor上的自定义PowerShell主机会将其视为错误。解决方案是在CMD中运行这些测试。因此,将它们包装为int .cmd文件,并使用- cmd:前缀运行。

关于reactjs - 从Powershell在Appveyor上运行Jest测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51195596/

相关文章:

javascript - react 表: How do I total (sum) values to each of the holeOne thru holeNine and display the sum as a value in out: 41?

powershell - Azure Active Directory 中可配置的 token 生命周期

javascript - Jest - 一个函数模拟多个测试文件的文件

javascript - Jest 在第一次失败后停止测试套件

javascript - 将本地模块导入为带有子组件的组件

javascript - 如何有条件地添加属性以 react DOM 元素

javascript - Flatlist 不会在状态更改时重新渲染

powershell - 使用字符串引用时,引用 Powershell 数组索引会产生意外结果

powershell - 与对象的属性进行比较时,Get-ADUser -Filter 失败

Typescript 期望 mockImplementation 为所有方法和属性提供模拟