Note
Return back to the README.md file.
I have used the recommended HTML W3C Validator to validate all of my HTML files.
| Validator | File | Screenshot | Notes |
|---|---|---|---|
| W3C Validator | 404.html | ![]() |
No errors found |
| W3C Validator | index.html | ![]() |
No errors found |
I have used the recommended CSS Jigsaw Validator to validate all of my CSS files.
| Directory | File | Screenshot | Notes |
|---|---|---|---|
| assets | style.css | ![]() |
No error on style.css file, errors marked from the libraries used |
I have used the recommended JShint Validator to validate all of my JS files.
I've tested my deployed project on multiple browsers to check for compatibility issues.
| Browser | Start Modal | In-Game | Instructions | Won Game | Game Over | Contact | 404 | Notes |
|---|---|---|---|---|---|---|---|---|
| Chrome | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Works as expected |
| Firefox | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Works as expected |
| Safari | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Works as expected |
I've tested my deployed project on multiple devices to check for responsiveness issues.
I've tested my deployed project using the Lighthouse Audit tool to check for any major issues.
| Page | Mobile | Desktop | Notes |
|---|---|---|---|
| Index | ![]() |
![]() |
Some minor warnings on accesibility |
| 404 | ![]() |
![]() |
Some minor warnings on accesibility |
Defensive programming was manually tested with the below user acceptance testing:
This game was tested by a registered nurse. The feedback given to me was positive as she found the gme to be 'fun and interactive'. However, there were a few typos noticed in the drug names. This has been fixed since then.
I have conducted a series of automated tests on my application.
I fully acknowledge and understand that, in a real-world scenario, an extensive set of additional tests would be more comprehensive.
I have used the Jest JavaScript testing framework to test the application functionality.
In order to work with Jest, I first had to initialize NPM.
npm init- Hit
enterfor all options, except for test command:, just typejest.
Add Jest to a list called Dev Dependencies in a dev environment:
npm install --save-dev jest
IMPORTANT: Initial configurations
When creating test files, the name of the file needs to be file-name.test.js in order for Jest to properly work.
Without the following, Jest won't properly run the tests:
npm install -D jest-environment-jsdom
Due to a change in Jest's default configuration, you'll need to add the following code to the top of the .test.js file:
/**
* @jest-environment jsdom
*/Make sure to include the name of all of your functions that are being tested in the game.test.js file.
if (typeof module !== 'undefined') module.exports = {
startGame,
isGuessedWordCorrect,
cardiacDictionary,
painDictionary,
getRandomDrug,
shuffleWord,
hasUserWonTheGame,
word,
hint,
correctGuessedWord,
canSubmit,
livesLeft,
livesTaken,
noOfCorrectWords,
gameIsOver,
gameIsWon,
gameIsExited,
noOfDrugs,
};Now that these steps have been undertaken, further tests can be written, and be expected to fail initially. Write JS code that can get the tests to pass as part of the Red-Green refactor process.
Once ready, to run the tests, use this command:
npm test
NOTE: To obtain a coverage report, use the following command:
npm test --coverage
Below are the results from the tests that I've written for this application:
| Test Suites | Tests | Screenshot |
|---|---|---|
| 1 passed | 18 passed | ![]() |
JS confetti undefined
Since js-confetti was implemented using a CDN, Jest testing failed to recognize it, causing interruptions during testing.
- To fix this, I have searched online on "How to get jest to ignore a function". CodeWithHugo explains that it can be done with an ignore line. Although, I understand that this should not be used all the time as all code should be tested. However, as
new JSConfetti()is an external function, I found it appropriate for this case. Please see below my implementation:
function ignoreLine() {
const jsConfetti = new JSConfetti();
if (gameIsWon) {
jsConfetti.addConfetti({
emojis: ['💊'],
});
} else if (gameIsExited) {
jsConfetti.addConfetti({
emojis: ['😭'],
});
} else if (gameIsOver) {
jsConfetti.addConfetti({
emojis: ['☠️'],
});
} else {
return;
}
}JS hint Configuration
The input of JSHint configuration into the game.test.js file resulted in errors, as it did not recognize the Jest environment. Below is the executed code and the error it threw:
/* jshint esversion: 11, jquery: true */
/**
* @jest-environment jsdom
*/- To fix this, I have changed the order of the lines:
/**
* @jest-environment jsdom
*/
/* jshint esversion: 11, jquery: true */Mocking The Index.html
When mocking the index.html, I ran into issues of where it was not recognising the email.js that I have implemented as an API.
beforeAll(() => {
let fs = require("fs");
let fileContents = fs.readFileSync("index.html", "utf-8");
document.open();
document.write(fileContents);
document.close();
});Please see below the error:
- To fix this, I've decided to discontinue mocking the index.html file because testing it became impractical due to numerous event handlers. Jest testing proved unsuitable for testing event handlers. Moving forward, I intend to explore alternative testing frameworks.
Overall, the majority of documentation on Jest testing pertains to the latest version, Jest v29. Troubleshooting became challenging for me as my project relied on Jest v26. While attempting to upgrade to Jest 29, I encountered difficulties due to changes in the syntax for mocking the DOM, and unfortunately, I couldn't find relevant documentation on this specific aspect. Therefore, I went back to Jest v26.
-
validateForm()function was not returning an error message feedback to the user when title input was empty:- To fix this, I have added
.innertextto the variableemailFeedback. Please see the implementation in the code block below:
emailFeedBack.innerText = "Please input a subject to your message";
- To fix this, I have added
-
When user double clicks on the guess-button, this moves on the next word even without the letter containers not filled. The multiple clicks was not being handled well.
- To fix this, I introduced an additional conditional statement within my guessButton event handler to ensure submission only occurs when the number of clicks (i.e.,
e.detail) equals 1. Additionally, I ensured that the guess button isdisabled(disabledset to true) whencanSubmitis false. This solution was inspired by insights from StackOverflow. . Please find my implementation in the code block below:
let hasBeenClicked = e.detail === 1; if (canSubmit && hasBeenClicked) { // Please see more of the code in game.js }
- To fix this, I introduced an additional conditional statement within my guessButton event handler to ensure submission only occurs when the number of clicks (i.e.,
-
When a user "double tap" on submit button, it skips a word on mobile devices. This occurence does not happen on chrome developer tools.
-
I have made several attempts to fix this and none have worked:
- Making
dblclickevent false as advised by StackOverflow:
Result: No change.
$(guessButton).dblclick(function(){ return false; });
- Adding a class with
pointer-event: nonewhennextWordis happening.
Result: No change.
.noevents { pointer-events: none; }
- Making a
touch-startevent handler:
Result: No change.
guessButton.addEventListener("touch-start", (e) => { // https://stackoverflow.com/questions/16715075/preventing-multiple-clicks-on-button // Prevents multiple clicks let hasBeenClicked = e.detail === 1; if (canSubmit && hasBeenClicked) { let guessedWord = makeGuessedWord(); if (isGuessedWordCorrect(word, guessedWord) === true) { $(".letter-container").addClass('correct'); setTimeout(function () { nextWord(); canSubmit = false; addCorrectGuessedWords(gameType, noOfDrugs, word); setUpGame(choice); if (gameIsWon) { wonGame(); } }, 500); } else { $(".letter-container").addClass('incorrect'); setTimeout(function () { $(".letter-container").removeClass('incorrect'); }, 1000); mistakeMade(livesLeft); isGameOver(correctGuessedWord); } } });
After numerous attempts to address the issue and seeking solutions from various resources, I've concluded that the problem might be related to the behavior of event handlers on mobile and touch screen devices. A lack of debugging tool on mobile devices makes it challenging to fix the bug.
- Making
Fixed Bugs
All previously closed/fixed bugs can be tracked here.




















































































