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

Add DEP: JavaScript Tests #4

Merged
merged 1 commit into from Sep 12, 2014
Merged

Conversation

treyhunner
Copy link
Member

This is a rough draft for a DEP detailing a path to adding JavaScript unit tests to Django.

This proposal currently only details my recommendation for a test suite and a native JS testing process (without a Python wrapper), including my reasoning.

I have also included some open questions that still need to be addressed.

Related django-developers mailing list thread


-- Jacob Kaplan-Moss

Django admin and gis contrib packages contain JavaScript code without any unit tests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most JavaScript in Django is tested through Selenium, it's far from ideal but it's something, this statement needs to be revisited IMO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Selenium tests are high-level functional/integration tests, not unit tests. Unit tests run much more quickly and test the JS API rather than the in-browser behavior of the JS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, but this posted right below "Code without tests is broken as designed." seems to imply that Django's JS is untested, that's not the case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, it would be good to clarify.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loic good point. I am making a guess (albeit one with good odds) that portions of the JavaScript code are not executed.

I've noticed in my own code that JavaScript tests often require more mocking than Python code because of the event-driven nature of JS. So my guess about the lacking nature of the existing tests may not be far from reality, but it's hard to tell for sure without a code coverage tool in place.

I should also note sinon for mocking and a code coverage tool (probably istanbul unless we use karma).

@treyhunner
Copy link
Member Author

Changes:

  1. Clarified the rationale
  2. Added counter-arguments against the perceived problem of running the automated tests using Node.js
  3. Added a high-level migration path

@akaariai
Copy link
Member

We are trying to get the DEP process started again.

Could you squash the commits into one? After that we can merge the proposal to drafts.

@treyhunner
Copy link
Member Author

@akaariai commits squashed. Thanks for restarting the process.

akaariai added a commit that referenced this pull request Sep 12, 2014
@akaariai akaariai merged commit c44eb94 into django:master Sep 12, 2014
@treyhunner treyhunner deleted the javascript-tests branch September 16, 2014 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants