Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Challenge tests should be done in browser #4201

Closed
BerkeleyTrue opened this issue Nov 6, 2015 · 22 comments
Closed

Challenge tests should be done in browser #4201

BerkeleyTrue opened this issue Nov 6, 2015 · 22 comments
Assignees
Labels
status: on the roadmap Long term plans and features.

Comments

@BerkeleyTrue
Copy link
Contributor

At the moment the only challenges that have solutions are bonfires and javascript challenges. I'm not sure jquery and html challenges would be testable at the moment.

The testing framework needs to be moved into a browser window so tests can be done on iFrames if required.

@ltegman
Copy link
Member

ltegman commented Nov 6, 2015

Can confirm any challenge with tests that rely on editor will not work in the testing framework. Currently there are 326 references to editor within the challenge tests.

@BerkeleyTrue
Copy link
Contributor Author

Yup. Will need to put on my thinking cap.

@BerkeleyTrue BerkeleyTrue added the status: on the roadmap Long term plans and features. label Aug 15, 2016
@systimotic
Copy link
Member

As far as I'm aware the tests are currently done in the browser. Can this issue be closed?
/cc @FreeCodeCamp/moderators

@dhcodes
Copy link
Contributor

dhcodes commented Dec 30, 2016

@systimotic thanks for looking at these issue deep-dives.

@raisedadead
Copy link
Member

I would have loved to chime in, but considering this is a very old one, @BerkeleyTrue is the best judge of what this was about then.

@BerkeleyTrue
Copy link
Contributor Author

Tests are still not run in the browser.

@raisedadead
Copy link
Member

Ahhhhh, now I get it, @systimotic @dhcodes, Berkeley is talking about, the npm run test-challenges, these are "unit tests" that are validated against default solutions in CI.

This is a build validation step that is currently in console environment only.

JS Challenges are tested for breaks in the CI step, by validating against the solutions that you may see with the seed code in the JSON files.

This is currently not possible for the jQuery and HTML challenges, and hence need migration to the browser window.

Hope this clarifies the understanding.

@systimotic
Copy link
Member

Ah, thank you for the clarification @raisedadead!
That's certainly an interesting problem. Should we label this help wanted?

@BerkeleyTrue BerkeleyTrue self-assigned this Jan 2, 2017
@BerkeleyTrue
Copy link
Contributor Author

I've assigned myself to this one.

@Greenheart
Copy link
Member

I've got some ideas on how to solve this. Please check #13016 (comment) 😊

@Bouncey
Copy link
Member

Bouncey commented Feb 10, 2017

An idea I have had for HTML testing is passing the HMTL string to react-render-html, and then use react-test-renderer to parse it into a javascript object which we can test easily enough.

@BerkeleyTrue
Copy link
Contributor Author

This is something that needs to be done in the browser with the same framework we use to test challenges when a user is using fcc. Abstracts will only introduce more issues and differences that cannot be accounted for.

@raisedadead
Copy link
Member

@BerkeleyTrue I have been researching lately for one of my day job assignments where we already have been doing testing on Karma and Jasmine (testing framework) to run tests in browser for over a year, and recently I have started some investigation on Headless browsers.

So, potentially we could see this implemented here too, with great Travis.

Chrome has:
https://developers.google.com/web/updates/2017/04/headless-chrome (working on all major OS vendors)

Mozilla has:
https://developer.mozilla.org/en-US/Firefox/Headless_mode

I know you are planning something, but should you be okay, I would like to take this opportunity and try out some prototype.

Let me know your thoughts.

@BerkeleyTrue
Copy link
Contributor Author

I have in my mind to move over to ava.js for testing (I've used it in several other projects and it is fantastic), but ava does not support browser testing. It does seem possible to do iframe testing using jsdom. If that is possible it might not be needed to do challenge testing in the browser. This is an untested theory but it would make challenge testing pretty fast as ava runs tests in parallel.

@QuincyLarson
Copy link
Contributor

@BerkeleyTrue What do you think of @raisedadead's proposed tool? Should we give him the green light to experiment with it while you work on other parts of the platform?

@raisedadead
Copy link
Member

raisedadead commented Oct 17, 2017

@BerkeleyTrue yup, ava.js is totally dope, and while I haven't yet official used it in any of my production projects, but having gone through some of the writeups and a tinkering around, I can clearly see why its on rage.

And, to the best of my knowledge, Karma is a (cross-platform) engine which supports any testing framework you plug it into. So, while I am yet to confirm if it will play well with ava.js, I am pretty sure it would be like adding any other library.

My main point here is that will headless browsers, we can work with a real-time browser in a CI environment, and this gives us a fair chance to create tests that make the platform stable(-er).

Meaning, we will not be faking any DOM, but its the actual DOM without a rendering UI, which is taken care of by headless browsers, and the fact that these are official implements of Chrome and Firefox, (maybe edge/ie and safari will catchup), is a good thing to have.

@BerkeleyTrue
Copy link
Contributor Author

@raisedadead if you can get ava working with Karma that would be great, but I suspect it will not be easy. We may end up using mocha/karma for challenge testing and ava for everything else.

@raisedadead
Copy link
Member

@BerkeleyTrue sure thing, I'll give this a try and let you know. Thanks for the feedback.

@QuincyLarson
Copy link
Contributor

@raisedadead Thanks for giving this a try. Have you had a chance to experiment with it much yet?

@raisedadead
Copy link
Member

Yup, @QuincyLarson I am checking with the AVA team for support for official adaptor for Karma.

@QuincyLarson
Copy link
Contributor

@raisedadead OK - great. Thanks for keeping us posted on this.

@QuincyLarson
Copy link
Contributor

I'm closing this issue as stale since it hasn't been active lately. If you think this is still relevant to the newly updated platform, please explain why, then reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: on the roadmap Long term plans and features.
Projects
None yet
Development

No branches or pull requests

8 participants