Skip to content

jobtrek/javascript-exercise-HakiEBIBI

 
 

Repository files navigation

JavaScript exercises

Some basic exercises to discover JS.

Setup

Install node.js on your system, you need node 22 ! Depending on the os, you may use the official repositories nodesource builds.

# clone the repository or download the exercises
# Move into the repository
cd ex-js
# Install dependencies
npm i
# Install playwright browser for e2e tests
npx playwright install

Check here if your distribution does not support playwright

Simple syntax exercises

Launch the tests by typing npm run test, this will launch all tests and rerun them on file changes. You can also launch test from your IDE. You can browse tests, they are located in files ending with .test.js.

  1. Basic conditions
  2. Manipulating strings
  3. Maths
  4. Arrays
  5. Objects

Interacting with browser and dom exercises

First you need to launch the dev server npm run dev, to see your results in the browser. The dev server must be started for the tests to execute correctly. Launch the tests by typing npx playwright test, if you encounter difficulties, you can run the tests in ui mode, to see which test fails : npx playwright test --ui.

  1. Dom basics
  2. Click events
  3. Input events
  4. Mouse and focus events
  5. Fetch data

Note for distributions not directly supported by playwright

You can easily run the playwright server on a docker container :

docker run --rm --network host --init -it mcr.microsoft.com/playwright:v1.48.2-noble /bin/sh
 -c "cd /home/pwuser && npx -y playwright@1.48.2 run-server --port 8080"

This will start a docker container with the playwright server and all the browsers binary and libraries.

Then, when running your playwright tests, just add an environment variable with the server location :

PW_TEST_CONNECT_WS_ENDPOINT=ws://localhost:8080/ npx playwright test
# Or with UI
PW_TEST_CONNECT_WS_ENDPOINT=ws://localhost:8080/ npx playwright test --ui-port=9090

With this setup, the test logic will run on the host, but the browsers in the container.

More information here.

About

dev-24-javascript-exercise-ex-js-empty created by GitHub Classroom

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 94.0%
  • HTML 6.0%