Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

unit test for node project (teams for education)

robertrodini1
robertrodini1

How to use the Input field for unit tests for node projects in Teams for Education? The online documentation doesn't use it. Is that because it is not implemented?

P.S. I would like to link to my Teams For Education example but I can't so I used change-calculator-CLI which is similar but not identical.

1 year ago

Voters

Comments

TopNew
1
GloriaWolff
GloriaWolff

The purpose of this document is to provide a unit test for node project (teams for education). This document will be used as a guide for any future changes made to the node project.Unit testing can be seen as both an executable specification and as a method to improve code quality. One of my friends asked me to visit https://www.resumehelpaustralia.com/ for help in essay. The goals of unit testing are to isolate faults, reduce time spent debugging and to ensure consistent results when refactoring the code base.

6 months ago
1
HarveyPederson
HarveyPederson

Hi, I want to know how to use the Input field for unit tests for node projects in Teams for Education and I am glad I have found my answer over here. Thanks all for your suggestions. I also found https://www.sportsgossip.com/modern-students-and-their-problems-in-education/ website on a google search in which I found about modern students and their problems in education.

7 months ago
1
robertrodini1
robertrodini1

Another alternative is to enter a representation of ^D on a separate line of the input value. This doesn't work as I have tried an HTML character code and ^D. I need Replit staff to say if there is a way to do this.

1 year ago
1
robertrodini1
robertrodini1

I've done some research and I think the answer may lie within the jest testing support for mocks. I would need to mock stdin since that's how I get simple input:

var fs = require("fs"); var input = fs.readFileSync(0).toString();

I would need help from Replit staff to see how to fit the mock into their use of jest. Here are a couple of articles on jest mocking:
https://medium.com/@altshort/unit-testing-node-cli-apps-with-jest-2cd4adc599fb
https://jestjs.io/docs/manual-mocks#mocking-node-modules

1 year ago
1
JacobBirch
JacobBirch

Inside of node, you can do something like:

let whateverToPrompt = prompt('Question here')

and refer to whateverToPrompt later to get the answer they put.

1 year ago
1
robertrodini1
robertrodini1

What you're suggesting is similar to the what I have in change-calculator-CLI project above. Reading from the tty is impossible in the unit test that I created for above.

Note that my question is specifically for unit test for Teams for Education projects where I am able to provide an input value for each test. Even this doesn't seem to work at all.

1 year ago
1
MichaelMcDowell
MichaelMcDowell

@robertrodini1

You ever figure this out? You're using unit tests and not the input/output test they have for education correct?

I was using the education input/output tests but trying to input 2 variables and just can't get that working. I've since been experimenting with unit tests and jest but haven't been able to handle prompt().

1 year ago
1
robertrodini1
robertrodini1

@MichaelMcDowell

No, but I reported it to Lena Sawyer from REPLIT. I am testing under Teams for Education. The problem is with programs with multiple, separate lines of input. Seems that the tests just time out (and thereby fail).

1 year ago
1
MichaelMcDowell
MichaelMcDowell

@robertrodini1

I've asked about the same thing a couple weeks ago here (https://community.replit.com/t/multiple-input-output-in-node-js/167). I'm also using Teams for Education.

Currently I use functions with inputs to run my unit tests, and have students enter values on the code side for variables that are sent to the the function. It would be ideal to allow the prompt() twice for the student instead. Currently it times out as you have said.

If you drum up a work around at any point, I'd love to hear about it. I'm still experimenting when I find time each week with a solution. I'm just not that skilled at Jest at this time.

1 year ago
1
robertrodini1
robertrodini1

@MichaelMcDowell

REPLIT has employee Lena Sawyer and I have her email. I report it to her and she forwarded to the engineering team.
If I hear back I will let you know.

1 year ago
Load more