Closed
Bug 1330071
Opened 8 years ago
Closed 8 years ago
Add a couple of basic unit tests for eslint rules (not automatic)
Categories
(Developer Infrastructure :: Lint and Formatting, defect)
Tracking
(firefox53 fixed)
RESOLVED
FIXED
mozilla53
| Tracking | Status | |
|---|---|---|
| firefox53 | --- | fixed |
People
(Reporter: standard8, Assigned: standard8)
References
Details
Attachments
(1 file)
I've just put together some tests for a couple of the eslint custom rules we're now using - they are based around the RuleTester that eslint provides.
I haven't hooked them up to infrastructure, but they can be run via:
```
cd tools/lint/eslint/eslint-plugin-mozilla
npm run test
```
That gives us something very basic that allows us to have some outline to make writing and testing rules simpler and quicker. Although we can't easily test every rule this way (see bug 1219152 comment 1), we should be able to test some of them.
I'm not doing this directly on bug 1219152, as I think there's other rules we can still write tests for (and potentially integrate with build/test systems), this is just to get something in the tree for future work.
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 2•8 years ago
|
||
Note: this is currently based on autoland, as it is waiting for bug 1329614 to land in central.
Comment 3•8 years ago
|
||
| mozreview-review | ||
Comment on attachment 8825524 [details]
Bug 1330071 - Add a couple of basic unit tests for our custom eslint rules. Currently these are not automatic.
https://reviewboard.mozilla.org/r/103640/#review104312
::: tools/lint/eslint/eslint-plugin-mozilla/tests/test-run-all.js:6
(Diff revision 1)
> +/* Any copyright is dedicated to the Public Domain.
> + * http://creativecommons.org/publicdomain/zero/1.0/ */
> +
> +"use strict";
> +
> +const RuleTester = require("../../node_modules/eslint/lib/testers/rule-tester.js");
You should just be able to require "eslint/lib/testers/rule-tester"
::: tools/lint/eslint/eslint-plugin-mozilla/tests/test-run-all.js:11
(Diff revision 1)
> +const RuleTester = require("../../node_modules/eslint/lib/testers/rule-tester.js");
> +const fs = require('fs');
> +
> +var ruleTester = new RuleTester();
> +
> +fs.readdir("tests/", (err, files) => {
Looks like this makes an assumption about cwd. Use __dirname instead
Attachment #8825524 -
Flags: review?(dtownsend) → review+
| Comment hidden (mozreview-request) |
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f3dd4bce1fed
Add a couple of basic unit tests for our custom eslint rules. Currently these are not automatic. r=mossop
Comment 6•8 years ago
|
||
| bugherder | ||
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox53:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
Updated•7 years ago
|
Product: Testing → Firefox Build System
Updated•6 years ago
|
Version: Version 3 → 3 Branch
Updated•3 years ago
|
Product: Firefox Build System → Developer Infrastructure
You need to log in
before you can comment on or make changes to this bug.
Description
•