Opened 5 years ago

Closed 15 months ago

#16193 closed New feature (fixed)

Use qunit to test javascript in django source

Reported by: mbraak@… Owned by: Nick Sandford
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@… 5 years ago.
qunit tests patch

Download all attachments as: .zip

Change History (12)

Changed 5 years ago by mbraak@…

Attachment: 16193.diff added

qunit tests patch

comment:1 Changed 5 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 5 years ago by Julien Phalip

Needs documentation: set
Triage Stage: UnreviewedAccepted
Type: Cleanup/optimizationNew 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 Changed 5 years ago by Jannis Leidel

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 5 years ago by Julien Phalip

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 5 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 2 years ago by Nick Sandford

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 2 years ago by Nick Sandford

Owner: changed from nobody to Nick Sandford
Status: newassigned

comment:10 Changed 20 months ago by Collin Anderson

Cc: cmawebsite@… added

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

comment:11 Changed 15 months ago by Tim Graham

Resolution: fixed
Status: assignedclosed

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