繁体   English   中英

如何使用webpack编译我的Javascript资产以进行Wallaby功能测试?

[英]How do I compile my Javascript assets with webpack for Wallaby feature tests?

我在一个虚假的Phoenix项目中使用Wallaby,该项目使用webpack编译资产。

但是我得到这个错误:

1) test users have names (MyApp.Web.LandingPagesTest)
     test/my_app/web/integration/landing_pages/landing_pages_test.exs:6
     ** (Wallaby.JSError) There was an uncaught javascript error:

     Could not find component Website.
       mountComponents (http://localhost:4001/js/index.js:71740)
       (anonymous function) (http://localhost:4001/js/index.js:71759)

显然这是由于我的资产未编译引起的。

如何运行webpack来编译我的资产供Wallaby在phantomjs中使用?

我只是在test_helper.exs中添加了一行来编译资产

ExUnit.start()
{:ok, _} = Application.ensure_all_started(:wallaby)
Application.put_env(:wallaby, :base_url, XmsWeb.Endpoint.url())
System.cmd("cd", ["assets", "&&", "./node_modules/webpack/bin/webpack.js"])

现在,当您mix test它们应该编译

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM