Testing JavaScript with PyScript

Samanja Cartagena
3 min readMay 23, 2023

Yes, it can be done 😎

At first, let’s create the boiler plate code for Vanilla JavaScript

Samanja Cartagena
Oops ! I accidentally uploaded a picture of a puppy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>

</body>

Now, let’s go to pyscript.net and install the CDN for PyScript.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
<title>Document</title>
</head>
<body>
<script></script>
<py-script>

</py-script>
</body>
</html>

Now, let’s start Testing 🤩

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
<script defer src="https://pyscript.net/latest/pyscript.js"></script>…

--

--

No responses yet