简体   繁体   English

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

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

I'm using Wallaby in a dummy Phoenix project that uses webpack to compile assets. 我在一个虚假的Phoenix项目中使用Wallaby,该项目使用webpack编译资产。

But I get this error: 但是我得到这个错误:

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)

This is obviously being caused by my assets not being compiled. 显然这是由于我的资产未编译引起的。

How can I run webpack to compile my assets for Wallaby to use in phantomjs? 如何运行webpack来编译我的资产供Wallaby在phantomjs中使用?

I just add a line into test_helper.exs that compiles the assets 我只是在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"])

now when you mix test they should compile 现在,当您mix test它们应该编译

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

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