Opened 4 years ago

Closed 6 weeks ago

#16193 closed New feature (fixed)

Use qunit to test javascript in django source

Reported by: mbraak@… Owned by: slurms
Component: Testing framework Version: master
Severity: Normal Keywords: testing javascript qunit
Cc: cmawebsite@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Use qunit to test javascript in django source, especially in contrib.admin.

I have a patch which tests some Date functions in core.js in the admin.

Attachments (1)

16193.diff (50.7 KB) - added by mbraak@… 4 years ago.
qunit tests patch

Download all attachments as: .zip

Change History (12)

Changed 4 years ago by mbraak@…

qunit tests patch

comment:1 Changed 4 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Code is in /tests/qunittests/

See README in this directory for instructions how to run the tests.

comment:3 Changed 4 years ago by julien

  • Needs documentation set
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Cleanup/optimization to New feature

Note that some similar work has been done in https://github.com/sebleier/django/tree/qunit
It'd be interesting to compare the two approaches, and also coordinate to avoid duplicating work.

See also #16122.

comment:4 follow-up: Changed 4 years ago by jezdez

  • Patch needs improvement set

Well, the approach we took on Github (Sebleier's fork) is much more generic and prepared for app centric test running.

comment:5 in reply to: ↑ 4 Changed 4 years ago by julien

Replying to jezdez:

Well, the approach we took on Github (Sebleier's fork) is much more generic and prepared for app centric test running.

I actually played a bit with that branch a couple of weeks ago and it's looking great. I was wondering if you guys had thought of a way to test the admin interface (e.g. dynamically adding or removing inlines)? This would require generating a DOM from the up-to-date admin templates and with some test data. Perhaps we need to introduce a management command to generate fresh HTML files from the latest admin codebase, so that these can be tested with the admin javascript via qunit. I haven't thought of it much beyond that, but I'll try to get to it next week.

comment:6 Changed 4 years ago by mbraak

I see that the sebleier/qunit branch is much further developed than I initially thought. I will add my tests to this branch.

comment:8 Changed 13 months ago by slurms

Figure we just want *something* to unit test the django admin javascript as a first pass to fixing the more general problem. PR here: https://github.com/django/django/pull/3003. Needs more tests, and still 31 jshint errors.

comment:9 Changed 13 months ago by slurms

  • Owner changed from nobody to slurms
  • Status changed from new to assigned

comment:10 Changed 7 months ago by collinanderson

  • Cc cmawebsite@… added

Do we still need this now that we have selenium tests?

comment:11 Changed 6 weeks ago by timgraham

  • Resolution set to fixed
  • Status changed from assigned to closed

In 2d0dead224b6448072b72b37d2fbcc8dc3afa007:

DEP 0003 -- Added JavaScript unit tests.

Setup QUnit, added tests, and measured test coverage.

Thanks to Nick Sanford for the initial tests.

Note: See TracTickets for help on using tickets.
Back to Top