简体   繁体   中英

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.

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?

I just add a line into test_helper.exs that compiles the assets

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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