Comments (10)
As of commit: 638635a
If I run npm test
I get, in my browser:
Am I missing something?
from js-looping-and-iteration-looping-code-along.
Here are some screenshots of the test not passing.
The code that they wrote was the one they copied and pasted from the Solution Branch.
from js-looping-and-iteration-looping-code-along.
@sgharms this is one of a handful of lessons that pass with the learn-co browser test system but fail when using regular mocha testing. Investigating why this happens.
from js-looping-and-iteration-looping-code-along.
So this happens because when you stub Math.random in a mocha file it copies your file-specific version of Math.random that got spun up as a requirement. It seems this issue also plagues new Date
, if we use that in any other tests.
Overcoming it is apparently possible, but incredibly crufty. Here's a git repo walking through the process using mockery
: https://github.com/newz2000/dice-tdd
My personal recommendation is to change the lab to utilize non-randoms. It would probably be less work than making this one work, and the amount of additional code interwoven into the normal lines would likely be very confusing for student.
Here's a screenshot of my specific failure pre-attempting to fix it:
As you can see, the function is returning different values for numbers of tails flipped pretty consistently, but the test itself isn't stubbing the correct Math.random instance, and therefore is failing to recognize that it is called, or force specific return values.
from js-looping-and-iteration-looping-code-along.
Good research @RylanBauermeister . It's so strange that it works on some machines but not others, I wonder if the internals of rand()
have changed between OS versions or some such. In any case, the reversion of the merge commit that brought in the random seems like a good strategy.
from js-looping-and-iteration-looping-code-along.
from js-looping-and-iteration-looping-code-along.
@geluso I believe the learn-browser dependency is the culprit. It's designed to de-scary mocha+chai ecosystem and is set up to look at a virtual DOM as a measure of success (ideal for dom-based challenges). we're testing to see if jettisoning that dep removes the breakage.
from js-looping-and-iteration-looping-code-along.
Another example for this issue learn-co-students/js-looping-and-iteration-looping-code-along-nyc-web-career-031119#12
from js-looping-and-iteration-looping-code-along.
Hey @geluso,
I've pushed up the rewritten content for this lab, removing the reliance on Math.random() and changing the tests and narrative a bit so this should no longer be an issue. Thanks for reporting!
from js-looping-and-iteration-looping-code-along.
Copy that! Saw the PR.
from js-looping-and-iteration-looping-code-along.
Related Issues (20)
- Learn not seeing the lab HOT 1
- Test not picking up presence of Math.random HOT 1
- Grammar issue
- Error: Cannot find module 'jsdom/lib/old-api' HOT 1
- Incorrect test code for Re:Coded Front End Web Development curriculum HOT 1
- Method naming on second assignment. HOT 1
- Code Along doesn't align with tests HOT 3
- Not Loading HOT 1
- wrong function name in assignment HOT 1
- Incorrect method name in test HOT 1
- Typo: Loop Body <li> bullet HOT 1
- Sequencing issue
- Test issue HOT 1
- Another solution in ES6 HOT 1
- Completed but not updating HOT 1
- Using Math.random() >= 0.5 as opposed to Math.random() < 0.5 Is a hard-coded requirement. HOT 1
- formatting typo at 'Loop Body' HOT 1
- Browser alert that Test site is Dangerous HOT 3
- Browser alert that Test site is Dangerous (Re-opening) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-looping-and-iteration-looping-code-along.