<div dir="ltr"><div>Hello,</div><div><br></div><div>I searched the list archives, Stack Overflow, Github, and the internet broadly, but did not see my question answered. This makes me think that I am approaching my problem from the wrong angle.</div><div><br></div><div>I have a small Flask project which serves a few single-page-applications in several javascript frameworks. My goal is to learn to write js front end web applications. It was much easier for me to build the server in Flask, Jinja2, and SQLAlchemy rather than use Node, which many of the js framework  tutorials assume. </div><div><br></div><div>On top of my unit tests written in python (pytest) and javascript (jasmine, jest, or karma), I also thought I’d write some integration tests with CasperJS or, later, to try PhantomCSS. The challenge here is that in order to automate the process I have to run a live server example (plenty of these around) while also running the CasperJS process. Since this is a learning project, none of this is necessary, but it helps me to learn how to do things “the right way.”</div><div><br></div><div>Ideally, I’d like to run the CasperJS integration tests through pytest. I’ve spent some time sketching out a test runner in Python that collects the test_*.js files by name and runs them in a threaded subprocess. It catches the return code, etc., from which I can infer success or failure. (Cool! I wrote my first threaded module.) Then I thought, it sure would be nice to add this as a pytest-plugin, then the server can be started as a fixture and the tests added in the normal test discovery phase. </div><div><br></div><div>There is actually a Github project that claims to do something like this for Django, but it doesn’t appear load or run the CasperJS files. The documentation for pytest allows for adding tests through the pytest_pycollect_additem hook. However, the functions assume an inspectable python object. Option one is to just add a naive python wrapper around the javascript tests and see what happens.</div><div><br></div><div>Option two would be to wrap the subprocess call in a way that I can return a subclass of _pytest.python.Function or to create a subclass of _pytest.main.FSCollection which acts like the PyCollection? I’m wondering if I can write subclasses of the Collection/Session and Function classes that I run along with the PyCollection lifecycle. It seems like to do this right, you’d want to give pytest an Item or Node class that mimics what it expects from introspecting python code. This at least is what I think after looking at pytest source.</div><div><br></div><div>Is this worth pursuing? Is there an obvious alternative, like Selenium? What can anyone recommend in terms of implementation?</div><div><br></div><div>I appreciate your insight and answers.</div><div><br></div><div>Luke Thomas Mergner</div><div>Glendale, CA </div><div><a href="mailto:lmergner@gmail.com">lmergner@gmail.com</a></div></div>