Node.js 使用Elm时测试套件在笑话中失败
我正在构建一个Typescript单页应用程序。其中一个端点返回已编译的Elm应用程序 运行jest测试时,出现以下错误:Node.js 使用Elm时测试套件在笑话中失败,node.js,typescript,jestjs,elm,Node.js,Typescript,Jestjs,Elm,我正在构建一个Typescript单页应用程序。其中一个端点返回已编译的Elm应用程序 运行jest测试时,出现以下错误: yarn run v1.7.0 $ jest PASS server/tests/experience/Albums.spec.ts PASS server/tests/server.spec.ts FAIL client/elm-stuff/packages/elm-lang/virtual-dom/2.0.4/tests/Native/TestHelpers
yarn run v1.7.0
$ jest
PASS server/tests/experience/Albums.spec.ts
PASS server/tests/server.spec.ts
FAIL client/elm-stuff/packages/elm-lang/virtual-dom/2.0.4/tests/Native/TestHelpers.js
● Test suite failed to run
ReferenceError: Elm is not defined
> 1 | Elm.Native.TestHelpers = {};
| ^
2 | Elm.Native.TestHelpers.make = function(localRuntime)
3 | {
4 | localRuntime.Native = localRuntime.Native || {};
at Object.<anonymous> (client/elm-stuff/packages/elm-lang/virtual-dom/2.0.4/tests/Native/TestHelpers.js:1:28)
Test Suites: 1 failed, 2 passed, 3 total
Tests: 2 passed, 2 total
Snapshots: 1 passed, 1 total
Time: 0.669s, estimated 1s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
我可以毫无问题地运行应用程序
我在实际应用程序中对Elm的唯一引用是在我的HTML索引文件中
<!DOCTYPE html>
<html>
<head>
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />
<link rel="stylesheet" href="/main.css">
<title>Print Albums</title>
</head>
<body>
<div id="elm-app"></div>
<script src="elm-compiled.js"></script>
<script>
const app = Elm.Main.embed(document.getElementById("elm-app"));
app.ports.grabToken.send(window.location.search);
</script>
</body>
</html>
印刷相册
const-app=Elm.Main.embed(document.getElementById(“Elm-app”);
app.ports.grabToken.send(window.location.search);
你知道会出什么问题吗?jest似乎出于某种原因进入了我的Elm依赖项,而不仅仅是我的测试文件
干杯好的,堆栈溢出再次被证明是一个伟大的橡皮鸭 发生的情况是:
- 我在client文件夹中开发Elm应用程序
- 客户机文件夹的某些依赖项具有与正在搜索测试的jest regexp匹配的测试文件夹李>
client
添加到jest忽略的模式列表中
testPathIgnorePatterns: [
"/node_modules/", "/client/"
],
testPathIgnorePatterns: [
"/node_modules/", "/client/"
],