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

HTML challenges do not warn users or run tests when there are syntax errors #49018

Open
ojeytonwilliams opened this issue Jan 13, 2023 · 4 comments · May be fixed by #54694
Open

HTML challenges do not warn users or run tests when there are syntax errors #49018

ojeytonwilliams opened this issue Jan 13, 2023 · 4 comments · May be fixed by #54694
Assignees
Labels
platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. status: on the roadmap Long term plans and features.

Comments

@ojeytonwilliams
Copy link
Contributor

Describe the bug
Syntax errors in HTML and multifile challenges stop the tests from running.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://www.freecodecamp.org/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-2
  2. Replace code with <script> ) </script>
  3. Click "Check Your Code..."
  4. See nothing

Expected behavior

The tests should still run, even with broken syntax. Otherwise challenge creators are overly limited in the kinds of lessons they can write.

This is trickier to do for HTML challenges than pure JS ones, since we first build the frame and then run the test code in it. When there's a syntax error, that's not possible. Instead we will probably need to create a separate environment for the test to run in. A JS test runner, perhaps?

@naomi-lgbt is there anything I missed?

@ojeytonwilliams ojeytonwilliams added the platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. label Jan 13, 2023
@naomi-lgbt
Copy link
Member

This behaviour is also present in the new JS curriculum we've been working on (which is where it was really an issue).

@Sembauke
Copy link
Member

Sembauke commented Jan 16, 2023

Javascript will not run if there are syntax errors in the code. The browser or JavaScript engine will stop executing the script and display an error message indicating where the syntax error occurred.

We are running the tests in the same eval() function as the executed code. I do not think we can prevent it with the current test runner.

@oriooctopus
Copy link
Contributor

oriooctopus commented Jan 17, 2023

Instead we will probably need to create a separate environment for the test to run in. A JS test runner, perhaps?

If we have two separate environments can they still reference one another?

This is trickier to do for HTML challenges than pure JS ones

Yeah, the pure JS ones should just be a matter of running each test individually and wrapping each evaluation in a try/catch block

To me, if there is an HTML error I think it's sufficient enough to just tell the user something roughly like "this test failed because the HTML is invalid". The catch though is how we can distinguish between an HTML error and a JavaScript error. Especially when the JavaScript referenced is not an external script

@Sembauke Sembauke added the status: on the roadmap Long term plans and features. label Feb 15, 2023
@ifhammohamed1111
Copy link

is this still open
/assign

@ojeytonwilliams ojeytonwilliams linked a pull request May 7, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. status: on the roadmap Long term plans and features.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants