-
Hello all - I'm building tests for an app/site at work and doing it with elixir-wallaby. However, the app/site is already done and written in JS/Vue. Unfortunately, I can't find any information out there about this sort of approach. It seems best to treat elixir-wallaby like I'm building a web scraper rather than a testing suite. So - I would bring the url I'm testing into the Application, maybe with HTTPoison, and write all my 'tests' in the /lib folder rather than /test. Any thoughts? Does that seem like a good way to solve the problem? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
Hi! This is an interesting use case of Wallaby. I think what i would do is create a new project with There are a couple of approaches we could take here: You would write your Wallaby tests as normal, but in your Application, you would start a process that starts a Port that starts your JavaScript application. This assumes you are running something like If your JS application has a non-deterministic start time, you'll probably want a helper that can hit an endpoint or a page that can signal to wallaby that it is ready and the tests can start. Another way to approach it would be to compile your JS app (similar to how the docs describe), and then start a Plug server and point it to your apps entry point (probably an index.html somwhere) using Plug.Static I think the second approach is probably the easiest. If this doesn't make sense, I would be happy to write you up an example repo that demonstrates this approach. |
Beta Was this translation helpful? Give feedback.
-
Here is a link to an example repository with commit by commit explanations on how you might setup up a new app to build and test a JS application. |
Beta Was this translation helpful? Give feedback.
-
@mhanberg So it turned out that this approach doesn't work in my situation. There's a separate backend that is required for the SPA to work so the static index.html page returned by that half of the code base is only part of the puzzle. I'm think I'm back to the drawing board and wondering about setting up a suite of tests outside of the code base that I can point to a url, whether it's a local host or the staging url on an external server. I found a breadcrumb here: https://elixirforum.com/t/wallaby-vs-hound/443/5#:~:text=support%20testing%20of-,SPAs,-%3F |
Beta Was this translation helpful? Give feedback.
-
Here is an example of starting an arbitrary process, waiting for it to be ready (this assumes it's a web server, which I think is a safe assumption in this case), and then runs tests on it. |
Beta Was this translation helpful? Give feedback.
-
@mhanberg thanks - yeah - i figured that out today finally. Thanks for your help with all this. The intermingling of technologies has had me confused, but this has been a great learning process. Thanks again! |
Beta Was this translation helpful? Give feedback.
Hi!
This is an interesting use case of Wallaby. I think what i would do is create a new project with
mix new test_suite --sup
, and install Wallaby.There are a couple of approaches we could take here:
You would write your Wallaby tests as normal, but in your Application, you would start a process that starts a Port that starts your JavaScript application. This assumes you are running something like
npm run start
that starts up a JS web server that serves your JS appIf your JS application has a non-deterministic start time, you'll probably want a helper that can hit an endpoint or a page that can signal to wallaby that it is ready and the tests can start.
Another way to approach it …