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 built-in 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:
1. Create a new project folder named fantasy-character-creation-stream.
2. Inside the project folder, create the following structure: fantasy-character-creation-stream src character-creator.js test character-creator.spec.js package.json
3. In your package.json file, add a test script. Remember to install Jest as a dev dependency.
4. In the character-creator.js file create a CharacterCreator class that extends the Duplex stream class from Node.jss built-in stream module. The class should process character creation data and output a formatted description.
5. The CharacterCreator class should take data about the characters class (Warrior, Mage, Route), gender (Male, Female, Other), and a fun fact about the character. 160
6. Write three-unit tests for your CharacterCreator class in the charactercreator.spec.js file. Each test should cover a diKerent aspect about the classs functionality:
a. Test 1: The CharacterCreator processes data correctly when written to.
b. Test 2: The CharacterCreator emits an error event when an empty string is written to it.
c. Test 3: The CharacterCreator transforms the data correctly when written to.
7. 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.
In this assignment, you will create a character

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!