Question: In this assignment, you will create a character creation system for a fantasy video game using Node.js s built - in stream module. You will
In this assignment, you will create a character creation system for a fantasy video game using Node.jss builtin stream module. You will use a Duplex stream to process character creation data and output a formatted character description. You will also write unit tests for your code using Jest, following TDD principles:
Instructions:
Create a new project folder named fantasycharactercreationstream.
Inside the project folder, create the following structure: fantasycharactercreationstream src charactercreator.js test charactercreator.spec.js package.json
In your package.json file, add a test script. Remember to install Jest as a dev dependency.
In the charactercreator.js file create a CharacterCreator class that extends the Duplex stream class from Node.jss builtin stream module. The class should process character creation data and output a formatted description.
The CharacterCreator class should take data about the characters class Warrior Mage, Route gender Male Female, Other and a fun fact about the character.
Write threeunit tests for your CharacterCreator class in the charactercreator.spec.js file. Each test should cover a diKerent aspect about the classs functionality:
a Test : The CharacterCreator processes data correctly when written to
b Test : The CharacterCreator emits an error event when an empty string is written to it
c Test : The CharacterCreator transforms the data correctly when written to
Follow TDD principles: write a failing test, make it pass, then refactor. Repeat this process for each unit test.
Hints:
Use the push method in your Duplex stream to output data.
Remember to call callback in your write method.
Use the done function in your Jest tests to handle asynchronous code.
Refer to the MoviesStream provided in this chapter for guidance.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
