D
Deno

help

In-browser testing

MGMark G11/2/2023
I need to run some tests in a browser (Chrome, Firefox, Safari). Either by running a full test suite in the browser (ideally I like to run the suite in Deno too) or by connecting to and automating the browser, doesn't really matter. I'd really like to do this from Deno, and not have to go back to some node test framework. Can anyone suggest anything related that they've had success with in Deno?
DAHDeno AI Helper11/2/2023
Based on the documentation, Deno has a built-in test runner that you can use for testing JavaScript or TypeScript code. You can define a test using the Deno.test API and run the test using the deno test subcommand. However, Deno does not support running tests directly in a web browser like Chrome, Firefox, or Safari. Deno is a runtime for executing JavaScript and TypeScript outside of the web browser, and it does not have built-in functionality for automating or connecting to web browsers. That being said, Deno is working towards aligning its web APIs to the various API specifications, and it shares a test suite with browsers like Chrome, Firefox, Safari, and Servo. This shared web platform test suite checks that all browsers adhere to the same web platform specifications, so your code can be portable across engines. You can view Deno's progress towards web compatibility on the web platform test dashboard. If you need to test DOM manipulation or other browser-specific features, Deno does offer some web platform APIs, but it does not support most of the DOM APIs related to visual representation. There are a few libraries that provide a lot of the APIs needed to take code that was designed to run in a web browser to be able to run under Deno, in order to generate HTML and CSS which can be shipped to a browser “pre-rendered”. In conclusion, while you can write and run tests in Deno, you cannot directly run these tests in a web browser or automate a web browser using Deno. You might need to use a different tool or framework if you need to run tests directly in a web browser.
Ccdoremus11/4/2023
It sounds like you want to do end-to-end testing. You can do that with deno-puppeteer. Take a look at my blog post on using this library: https://deno-blog.com/End-to-end_test_a_Deno_webapp_using_deno-puppeteer.2022-08-21
MMrcool11/4/2023
for a deno first framework there is https://github.com/lino-levan/astral

Looking for more? Join the community!