簡體   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