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

Fix "memory leaks" in tests #3124

Closed
ntwb opened this issue Jan 12, 2018 · 9 comments
Closed

Fix "memory leaks" in tests #3124

ntwb opened this issue Jan 12, 2018 · 9 comments
Labels
good first issue is good for newcomers status: ready to implement is ready to be worked on by someone type: tests an improvement to testing

Comments

@ntwb
Copy link
Member

ntwb commented Jan 12, 2018

Describe the issue. Is it a bug or a feature request (new rule, new option, etc.)?

17 tests currently fail Jest's new "Experimental Leak Detection" https://facebook.github.io/jest/blog/#experimental-leak-detection

Which rule, if any, is this issue related to?

Any/all

What CSS is needed to reproduce this issue?

n/a

What stylelint configuration is needed to reproduce this issue?

n/a

Which version of stylelint are you using?

master

How are you running stylelint: CLI, PostCSS plugin, Node API?

n/a

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

No

What did you expect to happen?

No tests to be flagged FAIL

What actually happened (e.g. what warnings or errors you are getting)?

Running npm run jest:detectleaks results in 17 tests failed:

FAIL lib/__tests__/ignore.test.js
FAIL lib/__tests__/needlessDisables.test.js
FAIL lib/__tests__/standalone-cache.test.js
FAIL lib/__tests__/standalone-maxWarnings.test.js
FAIL lib/__tests__/standalone-needlessDisables.test.js
FAIL lib/__tests__/standalone-syntax.test.js
FAIL lib/__tests__/standalone.test.js
FAIL lib/__tests__/stylelintignore-test/stylelintignore.test.js
FAIL lib/rules/declaration-property-value-blacklist/__tests__/index.js
FAIL lib/rules/function-url-quotes/__tests__/index.js
FAIL lib/rules/selector-no-qualifying-type/__tests__/index.js
FAIL lib/rules/unit-case/__tests__/index.js
FAIL system-tests/001/001.test.js
FAIL system-tests/002/002.test.js
FAIL system-tests/003/003.test.js
FAIL system-tests/005/005.test.js
FAIL system-tests/fix/fix.test.js

    EXPERIMENTAL FEATURE!
    Your test suite is leaking memory. Please ensure all references are cleaned.
    
    There is a number of things that can leak memory:
      - Async operations that have not finished (e.g. fs.readFile).
      - Timers not properly mocked (e.g. setInterval, setTimeout).
      - Keeping references to the global scope.
      
      at node_modules/jest/node_modules/jest-cli/build/test_scheduler.js:115:22

@ntwb ntwb added status: ready to implement is ready to be worked on by someone type: tests an improvement to testing labels Jan 12, 2018
@ntwb ntwb added the good first issue is good for newcomers label Jan 12, 2018
@hudochenkov
Copy link
Member

Is there a strategy for finding leaks? Jest warning is too generic. I would like to learn how to find leaks, but don't know how to do it.

@CAYdenberg
Copy link
Contributor

Yeah, this is not an easy problem. I ran it and got 35 failed test suites ... not sure what the difference would be.

@jeddy3
Copy link
Member

jeddy3 commented Apr 1, 2018

Ref: #3236 (comment)

001.test.js and 005.test.js appear to be slow running tests. I'm unsure if this is because of leaks or because of the tests themselves.

Additionally, isAutoprefixable.js might be a good candidate for fixing. See: #3242 (comment)

@hudochenkov
Copy link
Member

I was investigating memory leaks in tests. But without much success.

I run npm run jest:detectLeaks three times. Every time failing tests were different, but some of them were failing every time:

lib/__tests__/ignore.test.js
lib/__tests__/needlessDisables.test.js
lib/__tests__/standalone-cache.test.js
lib/__tests__/standalone-maxWarnings.test.js
lib/__tests__/standalone-needlessDisables.test.js
lib/__tests__/standalone-syntax.test.js
lib/__tests__/standalone.test.js
lib/__tests__/stylelintignore-test/stylelintignore.test.js
lib/rules/at-rule-empty-line-before/__tests__/index.js
lib/rules/declaration-property-value-blacklist/__tests__/index.js
lib/rules/function-url-quotes/__tests__/index.js
lib/rules/selector-max-empty-lines/__tests__/index.js
lib/rules/selector-no-qualifying-type/__tests__/index.js
system-tests/001/001.test.js
system-tests/002/002.test.js
system-tests/003/003.test.js
system-tests/005/005.test.js
system-tests/cli/cli.test.js
system-tests/fix/fix.test.js

I found the reason for leaks for two of them and created a PR: #3249.

Then I tried to find problem with at-rule-empty-line-before and selector-max-empty-lines. I think with these tests problem not with tests itself, but with the number of tests in a single file. 466 and 560 tests respectively. This conclusion came from a little experiment.

I've removed all rule code, except bare minimum:

const ruleMessages = require("../../utils/ruleMessages");
const ruleName = "at-rule-empty-line-before";
const messages = ruleMessages(ruleName, {
expected: "Expected empty line before at-rule",
rejected: "Unexpected empty line before at-rule"
});
const rule = function() {
return () => {};
};
rule.ruleName = ruleName;
rule.messages = messages;
module.exports = rule;

And I didn't use testRule to verify that testRule doesn't have leaks itself. I've used the core of testRule to create simple tests:

const stylelint = require("../../../standalone");
for (let i = 0; i < 700; i++) {
it("no description", () => {
return stylelint({
code: "a {\n\n @mixin foo;\n}",
config: {
rules: {
"at-rule-empty-line-before": ["always"]
}
}
}).then(() => {
// expect(output.results[0].warnings).toEqual([]);
// expect(output.results[0].parseErrors).toEqual([]);
expect(true).toBeTruthy();
});
});
}

npm run jest:detectleaks -- lib/rules/at-rule-empty-line-before/__tests__/index.js

With 700 tests there is always a memory leak detected. With 500 tests. Sometimes it detected, sometimes — not. That's why I think this is the problem with a number of tests, rather with test code or stylelint code itself. Possibly it's a problem with Jest.

I'll try to investigate further other tests.


While I was searching for leaks I did some profiling. I noticed that globby, table, and postcss-selector-parser are the slowest dependencies. Also style-search not very fast.

I used Chrome DevTools to profile:

node --inspect-brk bin/stylelint.js system-tests/001/stylesheet.css --config system-tests/001/config.json

The slowest rules were for selectors mostly.

@XhmikosR
Copy link
Member

I was about to make a new issue but GitHub got a 500 error and my issue was not posted and noticed this one :)

C:\Users\xmr\Desktop\stylelint>node -v
v12.16.1

C:\Users\xmr\Desktop\stylelint>npm run jest -- --logHeapUsage
> stylelint@13.2.0 jest C:\Users\xmr\Desktop\stylelint
> jest "--logHeapUsage"

 PASS  lib/rules/selector-max-empty-lines/__tests__/index.js (40 MB heap size)
 PASS  system-tests/005/005.test.js (49 MB heap size)
 PASS  system-tests/001/001.test.js (35 MB heap size)
 PASS  lib/rules/value-keyword-case/__tests__/index.js (69 MB heap size)
 PASS  lib/rules/selector-attribute-operator-space-before/__tests__/index.js (81 MB heap size)
 PASS  lib/rules/at-rule-empty-line-before/__tests__/index.js (87 MB heap size)
 PASS  lib/rules/selector-attribute-operator-space-after/__tests__/index.js (107 MB heap size)
 PASS  lib/rules/selector-no-qualifying-type/__tests__/index.js (113 MB heap size)
 PASS  lib/__tests__/standalone-syntax.test.js (113 MB heap size)
 PASS  lib/rules/function-calc-no-invalid/__tests__/index.js (74 MB heap size)
 PASS  lib/rules/function-url-quotes/__tests__/index.js (146 MB heap size)
 PASS  lib/rules/selector-attribute-brackets-space-inside/__tests__/index.js (130 MB heap size)
 PASS  lib/rules/no-eol-whitespace/__tests__/index.js (97 MB heap size)
 PASS  lib/rules/declaration-empty-line-before/__tests__/index.js (174 MB heap size)
 PASS  lib/rules/selector-pseudo-class-case/__tests__/index.js (79 MB heap size)
 PASS  lib/rules/property-case/__tests__/index.js (127 MB heap size)
 PASS  lib/rules/no-extra-semicolons/__tests__/index.js (110 MB heap size)
 PASS  lib/rules/unit-case/__tests__/index.js (137 MB heap size)
 PASS  lib/rules/rule-empty-line-before/__tests__/index.js (100 MB heap size)
 PASS  lib/rules/max-line-length/__tests__/index.js (132 MB heap size)
 PASS  lib/rules/selector-pseudo-element-case/__tests__/index.js (117 MB heap size)
 PASS  lib/rules/indentation/__tests__/rules.js (156 MB heap size)
 PASS  lib/__tests__/standalone.test.js (146 MB heap size)
 PASS  lib/rules/function-parentheses-space-inside/__tests__/index.js (172 MB heap size)
 PASS  lib/rules/color-named/__tests__/index.js (126 MB heap size)
 PASS  lib/rules/selector-combinator-space-after/__tests__/index.js (168 MB heap size)
 PASS  lib/rules/selector-max-type/__tests__/index.js (144 MB heap size)
 PASS  lib/rules/block-opening-brace-newline-before/__tests__/index.js (181 MB heap size)
 PASS  lib/rules/custom-property-empty-line-before/__tests__/index.js (161 MB heap size)
 PASS  lib/rules/media-feature-name-case/__tests__/index.js (188 MB heap size)
 PASS  lib/rules/property-no-unknown/__tests__/index.js (207 MB heap size)
 PASS  lib/rules/linebreaks/__tests__/index.js (228 MB heap size)
 PASS  lib/rules/function-name-case/__tests__/index.js (176 MB heap size)
 PASS  lib/rules/block-opening-brace-space-before/__tests__/index.js (205 MB heap size)
 PASS  lib/rules/length-zero-no-unit/__tests__/index.js (193 MB heap size)
 PASS  lib/rules/selector-type-no-unknown/__tests__/index.js (244 MB heap size)
 PASS  lib/rules/block-closing-brace-newline-after/__tests__/index.js (215 MB heap size)
 PASS  lib/rules/indentation/__tests__/functions.js (205 MB heap size)
 PASS  lib/rules/function-whitespace-after/__tests__/index.js (154 MB heap size)
 PASS  lib/rules/unit-no-unknown/__tests__/index.js (230 MB heap size)
 PASS  lib/rules/block-closing-brace-space-before/__tests__/index.js (220 MB heap size)
 PASS  lib/utils/parseCalcExpression/__tests__/parseCalcExpression.test.js (250 MB heap size)
 PASS  lib/rules/block-opening-brace-newline-after/__tests__/index.js (170 MB heap size)
 PASS  lib/rules/selector-list-comma-newline-after/__tests__/index.js (259 MB heap size)
 PASS  lib/rules/selector-combinator-space-before/__tests__/index.js (244 MB heap size)
 PASS  lib/rules/function-comma-newline-after/__tests__/index.js (178 MB heap size)
 PASS  lib/rules/function-comma-space-before/__tests__/index.js (281 MB heap size)
 PASS  lib/rules/media-query-list-comma-space-after/__tests__/index.js (149 MB heap size)
 PASS  lib/rules/declaration-block-no-duplicate-properties/__tests__/index.js (201 MB heap size)
 PASS  lib/rules/at-rule-name-space-after/__tests__/index.js (292 MB heap size)
 PASS  lib/rules/function-max-empty-lines/__tests__/index.js (169 MB heap size)
 PASS  lib/rules/block-closing-brace-empty-line-before/__tests__/index.js (211 MB heap size)
 PASS  lib/rules/block-closing-brace-space-after/__tests__/index.js (301 MB heap size)
 PASS  lib/rules/media-query-list-comma-newline-after/__tests__/index.js (170 MB heap size)
 PASS  lib/rules/function-comma-space-after/__tests__/index.js (231 MB heap size)
 PASS  lib/rules/block-opening-brace-space-after/__tests__/index.js (326 MB heap size)
 PASS  lib/rules/unit-blacklist/__tests__/index.js (195 MB heap size)
 PASS  lib/rules/media-query-list-comma-space-before/__tests__/index.js (239 MB heap size)
 PASS  lib/rules/declaration-block-no-redundant-longhand-properties/__tests__/index.js (334 MB heap size)
 PASS  lib/rules/selector-pseudo-class-parentheses-space-inside/__tests__/index.js (200 MB heap size)
 PASS  lib/rules/shorthand-property-no-redundant-values/__tests__/index.js (253 MB heap size)
 PASS  lib/rules/no-descending-specificity/__tests__/index.js (361 MB heap size)
 PASS  lib/rules/function-parentheses-newline-inside/__tests__/index.js (276 MB heap size)
 PASS  lib/rules/no-duplicate-selectors/__tests__/index.js (221 MB heap size)
 PASS  lib/rules/selector-max-specificity/__tests__/index.js (217 MB heap size)
 PASS  lib/rules/selector-type-case/__tests__/index.js (289 MB heap size)
 PASS  lib/rules/declaration-block-semicolon-space-before/__tests__/index.js (233 MB heap size)
 PASS  lib/rules/media-feature-name-no-vendor-prefix/__tests__/index.js (240 MB heap size)
 PASS  lib/rules/declaration-block-no-shorthand-property-overrides/__tests__/index.js (303 MB heap size)
 PASS  lib/rules/block-closing-brace-newline-before/__tests__/index.js (255 MB heap size)
 PASS  lib/rules/value-list-comma-space-after/__tests__/index.js (256 MB heap size)
 PASS  lib/rules/font-family-name-quotes/__tests__/index.js (316 MB heap size)
 PASS  lib/rules/no-missing-end-of-source-newline/__tests__/index.js (269 MB heap size)
 PASS  lib/rules/comment-empty-line-before/__tests__/index.js (264 MB heap size)
 PASS  lib/rules/selector-list-comma-space-after/__tests__/index.js (290 MB heap size)
 PASS  lib/rules/selector-max-id/__tests__/index.js (285 MB heap size)
 PASS  lib/rules/selector-no-vendor-prefix/__tests__/index.js (349 MB heap size)
 PASS  lib/rules/selector-list-comma-space-before/__tests__/index.js (305 MB heap size)
 PASS  lib/rules/at-rule-no-vendor-prefix/__tests__/index.js (304 MB heap size)
 PASS  lib/__tests__/disableRanges.test.js (308 MB heap size)
 PASS  lib/rules/indentation/__tests__/javascript.js (360 MB heap size)
 PASS  lib/rules/declaration-block-semicolon-newline-after/__tests__/index.js (319 MB heap size)
 PASS  lib/rules/indentation/__tests__/html.js (322 MB heap size)
 PASS  lib/rules/function-url-no-scheme-relative/__tests__/index.js (381 MB heap size)
 PASS  lib/rules/function-url-scheme-whitelist/__tests__/index.js (340 MB heap size)
 PASS  system-tests/002/002.test.js (319 MB heap size)
 PASS  lib/rules/function-comma-newline-before/__tests__/index.js (396 MB heap size)
 PASS  lib/rules/at-rule-name-newline-after/__tests__/index.js (353 MB heap size)
 PASS  lib/rules/font-weight-notation/__tests__/index.js (340 MB heap size)
 PASS  lib/rules/value-list-comma-space-before/__tests__/index.js (405 MB heap size)
 PASS  lib/rules/selector-class-pattern/__tests__/index.js (357 MB heap size)
 PASS  system-tests/004/004.test.js (358 MB heap size)
 PASS  lib/rules/selector-list-comma-newline-before/__tests__/index.js (421 MB heap size)
 PASS  lib/rules/color-no-invalid-hex/__tests__/index.js (367 MB heap size)
 PASS  lib/rules/indentation/__tests__/at-rules.js (365 MB heap size)
 PASS  lib/rules/string-quotes/__tests__/index.js (431 MB heap size)
 PASS  lib/rules/selector-max-compound-selectors/__tests__/index.js (387 MB heap size)
 PASS  lib/__tests__/plugins.test.js (440 MB heap size)
 PASS  lib/rules/function-calc-no-unspaced-operator/__tests__/index.js (385 MB heap size)
 PASS  lib/__tests__/ignore.test.js (390 MB heap size)
 PASS  lib/rules/declaration-block-semicolon-space-after/__tests__/index.js (400 MB heap size)
 PASS  lib/rules/media-feature-range-operator-space-after/__tests__/index.js (456 MB heap size)
 PASS  lib/rules/media-feature-parentheses-space-inside/__tests__/index.js (412 MB heap size)
 PASS  lib/rules/number-leading-zero/__tests__/index.js (399 MB heap size)
 PASS  lib/rules/comment-word-blacklist/__tests__/index.js (475 MB heap size)
 PASS  lib/formatters/__tests__/verboseFormatter.test.js (411 MB heap size)
 PASS  lib/rules/selector-max-combinators/__tests__/index.js (485 MB heap size)
 PASS  lib/__tests__/cli.test.js (421 MB heap size)
 PASS  lib/rules/comment-whitespace-inside/__tests__/index.js (429 MB heap size)
 PASS  lib/rules/declaration-colon-space-after/__tests__/index.js (432 MB heap size)
 PASS  lib/rules/unicode-bom/__tests__/index.js (499 MB heap size)
 PASS  lib/rules/declaration-bang-space-before/__tests__/index.js (431 MB heap size)
 PASS  lib/rules/unit-whitelist/__tests__/index.js (444 MB heap size)
 PASS  lib/rules/selector-pseudo-class-no-unknown/__tests__/index.js (516 MB heap size)
 PASS  lib/rules/media-feature-range-operator-space-before/__tests__/index.js (441 MB heap size)
 PASS  lib/rules/media-feature-colon-space-before/__tests__/index.js (453 MB heap size)
 PASS  lib/rules/value-list-comma-newline-after/__tests__/index.js (524 MB heap size)
 PASS  lib/rules/at-rule-name-case/__tests__/index.js (454 MB heap size)
 PASS  lib/rules/selector-max-class/__tests__/index.js (533 MB heap size)
 PASS  lib/rules/selector-max-attribute/__tests__/index.js (459 MB heap size)
 PASS  lib/rules/time-min-milliseconds/__tests__/index.js (475 MB heap size)
 PASS  lib/rules/selector-attribute-quotes/__tests__/index.js (552 MB heap size)
 PASS  lib/rules/function-url-scheme-blacklist/__tests__/index.js (467 MB heap size)
 PASS  lib/rules/value-list-max-empty-lines/__tests__/index.js (485 MB heap size)
 PASS  lib/rules/max-nesting-depth/__tests__/index.js (486 MB heap size)
 PASS  lib/rules/media-feature-name-no-unknown/__tests__/index.js (557 MB heap size)
 PASS  lib/rules/selector-max-universal/__tests__/index.js (489 MB heap size)
 PASS  lib/rules/media-feature-colon-space-after/__tests__/index.js (495 MB heap size)
 PASS  lib/rules/declaration-colon-space-before/__tests__/index.js (324 MB heap size)
 PASS  lib/utils/__tests__/isStandardSyntaxDeclaration.test.js (495 MB heap size)
 PASS  lib/__tests__/standalone-cache.test.js (499 MB heap size)
 PASS  lib/utils/__tests__/validateOptions.test.js (327 MB heap size)
 PASS  lib/rules/function-linear-gradient-no-nonstandard-direction/__tests__/index.js (518 MB heap size)
 PASS  lib/rules/selector-max-pseudo-class/__tests__/index.js (519 MB heap size)
 PASS  lib/rules/number-max-precision/__tests__/index.js (337 MB heap size)
 PASS  lib/rules/selector-pseudo-element-colon-notation/__tests__/index.js (524 MB heap size)
 PASS  lib/rules/declaration-bang-space-after/__tests__/index.js (528 MB heap size)
 PASS  lib/rules/at-rule-semicolon-newline-after/__tests__/index.js (357 MB heap size)
 PASS  lib/rules/selector-descendant-combinator-no-non-space/__tests__/index.js (534 MB heap size)
 PASS  lib/rules/no-unknown-animations/__tests__/index.js (367 MB heap size)
 PASS  lib/__tests__/standalone-formatter.test.js (294 MB heap size)
 PASS  lib/rules/media-query-list-comma-newline-before/__tests__/index.js (548 MB heap size)
 PASS  lib/rules/selector-nested-pattern/__tests__/index.js (375 MB heap size)
 PASS  lib/__tests__/processors.test.js (302 MB heap size)
 PASS  lib/rules/color-hex-case/__tests__/index.js (387 MB heap size)
 PASS  lib/rules/declaration-colon-newline-after/__tests__/index.js (562 MB heap size)
 PASS  lib/rules/declaration-block-semicolon-newline-before/__tests__/index.js (316 MB heap size)
 PASS  lib/rules/function-blacklist/__tests__/index.js (400 MB heap size)
 PASS  lib/rules/media-feature-name-whitelist/__tests__/index.js (572 MB heap size)
 PASS  lib/rules/media-feature-name-blacklist/__tests__/index.js (328 MB heap size)
 PASS  lib/__tests__/disableRanges-integration.test.js (580 MB heap size)
 PASS  lib/rules/color-hex-length/__tests__/index.js (402 MB heap size)
 PASS  lib/rules/media-feature-name-value-whitelist/__tests__/index.js (331 MB heap size)
 PASS  lib/utils/__tests__/getUnitFromValueNode.test.js (415 MB heap size)
 PASS  lib/rules/indentation/__tests__/selectors.js (587 MB heap size)
 PASS  lib/__tests__/integration.test.js (348 MB heap size)
 PASS  lib/rules/number-no-trailing-zeros/__tests__/index.js (418 MB heap size)
 PASS  lib/rules/declaration-block-trailing-semicolon/__tests__/index.js (598 MB heap size)
 PASS  lib/rules/selector-pseudo-class-blacklist/__tests__/index.js (358 MB heap size)
 PASS  lib/rules/property-blacklist/__tests__/index.js (428 MB heap size)
 PASS  lib/rules/function-whitelist/__tests__/index.js (603 MB heap size)
 PASS  lib/rules/declaration-property-unit-whitelist/__tests__/index.js (363 MB heap size)
 PASS  lib/rules/selector-id-pattern/__tests__/index.js (445 MB heap size)
 PASS  lib/utils/__tests__/isStandardSyntaxUrl.test.js (374 MB heap size)
 PASS  lib/rules/block-no-empty/__tests__/index.js (611 MB heap size)
 PASS  lib/rules/at-rule-no-unknown/__tests__/index.js (382 MB heap size)
 PASS  lib/__tests__/needlessDisables.test.js (449 MB heap size)
 PASS  lib/rules/selector-pseudo-element-whitelist/__tests__/index.js (620 MB heap size)
 PASS  lib/utils/__tests__/isStandardSyntaxAtRule.test.js (463 MB heap size)
 PASS  lib/rules/font-family-no-missing-generic-family-keyword/__tests__/index.js (397 MB heap size)
 PASS  lib/rules/property-whitelist/__tests__/index.js (641 MB heap size)
 PASS  lib/rules/declaration-block-single-line-max-declarations/__tests__/index.js (474 MB heap size)
 PASS  lib/utils/__tests__/isStandardSyntaxRule.test.js (643 MB heap size)
 PASS  lib/rules/selector-pseudo-class-whitelist/__tests__/index.js (411 MB heap size)
 PASS  lib/__tests__/printConfig.test.js (477 MB heap size)
 PASS  lib/rules/selector-combinator-whitelist/__tests__/index.js (652 MB heap size)
 PASS  lib/rules/value-list-comma-newline-before/__tests__/index.js (419 MB heap size)
 PASS  lib/rules/no-duplicate-at-import-rules/__tests__/index.js (489 MB heap size)
 PASS  lib/rules/selector-combinator-blacklist/__tests__/index.js (657 MB heap size)
 PASS  lib/rules/at-rule-semicolon-space-before/__tests__/index.js (422 MB heap size)
 PASS  lib/rules/selector-attribute-operator-whitelist/__tests__/index.js (668 MB heap size)
 PASS  lib/formatters/__tests__/stringFormatter.test.js (496 MB heap size)
 PASS  lib/rules/selector-pseudo-element-blacklist/__tests__/index.js (430 MB heap size)
 PASS  lib/rules/selector-attribute-operator-blacklist/__tests__/index.js (677 MB heap size)
 PASS  lib/__tests__/invalidScopeDisables.test.js (509 MB heap size)
 PASS  lib/rules/declaration-property-value-blacklist/__tests__/index.js (445 MB heap size)
 PASS  lib/__tests__/postcssPlugin.test.js (688 MB heap size)
 PASS  lib/rules/declaration-property-unit-blacklist/__tests__/index.js (518 MB heap size)
 PASS  lib/__tests__/extends.test.js (455 MB heap size)
 PASS  lib/rules/keyframes-name-pattern/__tests__/index.js (697 MB heap size)
 PASS  lib/utils/__tests__/isSharedLineComment.test.js (528 MB heap size)
 PASS  lib/rules/no-empty-first-line/__tests__/index.js (457 MB heap size)
 PASS  lib/rules/color-no-hex/__tests__/index.js (705 MB heap size)
 PASS  lib/rules/string-no-newline/__tests__/index.js (537 MB heap size)
 PASS  lib/utils/__tests__/findFontFamily.test.js (467 MB heap size)
 PASS  lib/rules/font-family-no-duplicate-names/__tests__/index.js (719 MB heap size)
 PASS  lib/__tests__/stylelintignore-test/stylelintignore.test.js (480 MB heap size)
 PASS  lib/rules/at-rule-blacklist/__tests__/index.js (540 MB heap size)
 PASS  lib/__tests__/standalone-parseErrors.test.js (721 MB heap size)
 PASS  lib/rules/no-empty-source/__tests__/index.js (490 MB heap size)
 PASS  lib/rules/indentation/__tests__/comments.js (548 MB heap size)
 PASS  lib/utils/__tests__/isStandardSyntaxTypeSelector.test.js (735 MB heap size)
 PASS  lib/rules/custom-media-pattern/__tests__/index.js (492 MB heap size)
 PASS  lib/rules/custom-property-pattern/__tests__/index.js (558 MB heap size)
 PASS  lib/rules/keyframe-declaration-no-important/__tests__/index.js (744 MB heap size)
 PASS  lib/formatters/__tests__/unixFormatter.test.js (566 MB heap size)
 PASS  lib/rules/at-rule-whitelist/__tests__/index.js (499 MB heap size)
 PASS  lib/utils/__tests__/findListStyleType.test.js (743 MB heap size)
 PASS  lib/utils/__tests__/isMap.test.js (576 MB heap size)
 PASS  lib/rules/no-invalid-double-slash-comments/__tests__/index.js (515 MB heap size)
 PASS  lib/utils/__tests__/report.test.js (754 MB heap size)
 PASS  lib/__tests__/normalizeRuleSettings.test.js (587 MB heap size)
 PASS  lib/utils/__tests__/isStandardSyntaxSelector.test.js (518 MB heap size)
 PASS  lib/__tests__/standalone-needlessDisables.test.js (767 MB heap size)
 PASS  lib/utils/__tests__/findAnimationName.test.js (528 MB heap size)
 PASS  lib/__tests__/normalizeRuleSettings-integration.test.js (591 MB heap size)
 PASS  lib/rules/declaration-property-value-whitelist/__tests__/index.js (774 MB heap size)
 PASS  lib/utils/__tests__/addEmptyLineAfter.test.js (602 MB heap size)
 PASS  lib/rules/comment-no-empty/__tests__/index.js (537 MB heap size)
 PASS  lib/rules/at-rule-property-requirelist/__tests__/index.js (778 MB heap size)
 PASS  lib/__tests__/standalone-invalidScopeDisables.test.js (604 MB heap size)
 PASS  lib/__tests__/message.test.js (540 MB heap size)
 PASS  lib/utils/__tests__/isStandardSyntaxCombinator.test.js (789 MB heap size)
 PASS  lib/__tests__/reportUnknownRuleNames.test.js (613 MB heap size)
 PASS  lib/rules/declaration-no-important/__tests__/index.js (553 MB heap size)
 PASS  lib/utils/__tests__/hasEmptyLine.test.js (790 MB heap size)
 PASS  lib/utils/__tests__/matchesStringOrRegExp.test.js (625 MB heap size)
 PASS  lib/__tests__/createLinter.test.js (563 MB heap size)
 PASS  lib/utils/__tests__/beforeBlockString.test.js (800 MB heap size)
 PASS  lib/__tests__/ignoreDisables.test.js (627 MB heap size)
 PASS  lib/utils/__tests__/containsString.test.js (564 MB heap size)
 PASS  lib/utils/__tests__/hasBlock.test.js (810 MB heap size)
 PASS  lib/formatters/__tests__/compactFormatter.test.js (637 MB heap size)
 PASS  lib/utils/__tests__/nodeContextLookup.test.js (574 MB heap size)
 PASS  lib/__tests__/standalone-maxWarnings.test.js (820 MB heap size)
 PASS  lib/__tests__/standalone-deprecations.test.js (649 MB heap size)
 PASS  lib/utils/__tests__/nextNonCommentNode.test.js (583 MB heap size)
 PASS  lib/utils/__tests__/isLogicalCombination.test.js (821 MB heap size)
 PASS  lib/utils/__tests__/isFirstNested.test.js (653 MB heap size)
 PASS  lib/utils/__tests__/isAfterSingleLineComment.test.js (585 MB heap size)
 PASS  lib/utils/__tests__/removeEmptyLineAfter.test.js (832 MB heap size)
 PASS  lib/utils/__tests__/isCustomElement.test.js (664 MB heap size)
 PASS  lib/utils/__tests__/filterFilePaths.test.js (593 MB heap size)
 PASS  lib/utils/__tests__/isKeyframeRule.test.js (475 MB heap size)
 PASS  lib/rules/linebreaks/__tests__/integration.test.js (673 MB heap size)
 PASS  lib/utils/__tests__/isBlocklessAtRuleAfterBlocklessAtRule.test.js (603 MB heap size)
 PASS  lib/utils/__tests__/isStandardSyntaxValue.test.js (676 MB heap size)
 PASS  system-tests/ignoreFile/ignoreFile.test.js (482 MB heap size)
 PASS  lib/utils/__tests__/isBlocklessAtRuleAfterSameNameBlocklessAtRule.test.js (613 MB heap size)
 PASS  lib/utils/__tests__/checkInvalidCLIOptions.test.js (685 MB heap size)
 PASS  lib/utils/__tests__/isStandardSyntaxMediaFeatureName.test.js (487 MB heap size)
 PASS  lib/utils/__tests__/addEmptyLineBefore.test.js (615 MB heap size)
 PASS  lib/utils/__tests__/removeEmptyLineBefore.test.js (697 MB heap size)
 PASS  lib/utils/__tests__/optionsMatches.test.js (496 MB heap size)
 PASS  lib/utils/__tests__/getPreviousNonSharedLineCommentNode.test.js (624 MB heap size)
 PASS  lib/utils/__tests__/blurInterpolation.test.js (697 MB heap size)
 PASS  lib/utils/__tests__/isAfterComment.test.js (505 MB heap size)
 PASS  lib/utils/__tests__/checkAgainstRule.test.js (634 MB heap size)
 PASS  lib/utils/__tests__/getNextNonSharedLineCommentNode.test.js (707 MB heap size)
 PASS  lib/formatters/__tests__/disableOptionsReportStringFormatter.test.js (506 MB heap size)
 PASS  lib/utils/__tests__/isStandardSyntaxProperty.test.js (636 MB heap size)
 PASS  lib/utils/__tests__/validateObjectWithArrayProps.test.js (717 MB heap size)
 PASS  lib/utils/__tests__/isCustomProperty.test.js (515 MB heap size)
 PASS  lib/utils/__tests__/hasEmptyBlock.test.js (646 MB heap size)
 PASS  lib/utils/__tests__/getSchemeFromUrl.test.js (719 MB heap size)
 PASS  lib/utils/__tests__/declarationValueIndex.test.js (525 MB heap size)
 PASS  lib/testUtils/__tests__/mergeTestDescriptions.test.js (655 MB heap size)
 PASS  lib/utils/__tests__/isCounterResetCustomIdentValue.test.js (728 MB heap size)
 PASS  lib/utils/__tests__/isStandardSyntaxFunction.test.js (534 MB heap size)
 PASS  lib/utils/__tests__/isLessVariable.test.js (665 MB heap size)
 PASS  lib/utils/__tests__/functionArgumentsSearch.test.js (738 MB heap size)
 PASS  lib/utils/__tests__/ruleMessages.test.js (534 MB heap size)
 PASS  lib/__tests__/defaultSeverity.test.js (665 MB heap size)
 PASS  lib/utils/__tests__/isStandardSyntaxMediaFeature.test.js (748 MB heap size)
 PASS  lib/utils/__tests__/isKeyframeSelector.test.js (544 MB heap size)
 PASS  lib/utils/__tests__/hasInterpolation.test.js (674 MB heap size)
 PASS  lib/utils/__tests__/isSingleLineString.test.js (748 MB heap size)
 PASS  lib/utils/__tests__/isCustomMediaQuery.test.js (553 MB heap size)
 PASS  lib/utils/__tests__/isMathFunction.test.js (683 MB heap size)
 PASS  lib/utils/__tests__/isCounterIncrementCustomIdentValue.test.js (757 MB heap size)
 PASS  lib/utils/__tests__/blockString.test.js (561 MB heap size)
 PASS  lib/__tests__/standalone-quiet.test.js (692 MB heap size)
 PASS  lib/utils/__tests__/isVariable.test.js (767 MB heap size)
 PASS  lib/utils/__tests__/isOnlyWhitespace.test.js (570 MB heap size)
 PASS  lib/__tests__/formatters.test.js (700 MB heap size)
 PASS  lib/utils/__tests__/isNumbery.test.js (775 MB heap size)
 PASS  lib/utils/__tests__/isValidHex.test.js (571 MB heap size)
 PASS  lib/utils/__tests__/atRuleParamIndex.test.js (701 MB heap size)
 PASS  lib/utils/__tests__/findAtRuleContext.test.js (776 MB heap size)
 PASS  lib/utils/__tests__/isValidFontSize.test.js (580 MB heap size)
 PASS  lib/utils/__tests__/isCustomPropertySet.test.js (710 MB heap size)
 PASS  lib/utils/__tests__/isRangeContextMediaFeature.test.js (785 MB heap size)
 PASS  lib/utils/__tests__/isCustomSelector.test.js (589 MB heap size)
 PASS  lib/formatters/__tests__/jsonFormatter.test.js (719 MB heap size)
 PASS  lib/utils/__tests__/blurComments.test.js (794 MB heap size)
 PASS  lib/utils/__tests__/blurFunctionArguments.test.js (598 MB heap size)
 PASS  lib/utils/__tests__/getFormatterOptionsText.test.js (727 MB heap size)
 PASS  lib/rules/selector-pseudo-element-no-unknown/__tests__/index.js (605 MB heap size)
 PASS  lib/rules/value-no-vendor-prefix/__tests__/index.js (824 MB heap size)
 PASS  lib/rules/property-no-vendor-prefix/__tests__/index.js (747 MB heap size)
 PASS  lib/rules/max-empty-lines/__tests__/index.js (638 MB heap size)
 PASS  system-tests/outputFile/outputFile.test.js (821 MB heap size)
 PASS  system-tests/cli/cli.test.js (647 MB heap size)
 PASS  system-tests/fix/fix.test.js (767 MB heap size)
 PASS  system-tests/003/003.test.js (855 MB heap size)

Test Suites: 305 passed, 305 total
Tests:       4 skipped, 15102 passed, 15106 total
Snapshots:   9 passed, 9 total
Time:        49.688s
Ran all test suites.

And with npm run jest:detectleaks:

Summary of all failing tests
 FAIL  system-tests/003/003.test.js
  ● Test suite failed to run

    EXPERIMENTAL FEATURE!
    Your test suite is leaking memory. Please ensure all references are cleaned.

    There is a number of things that can leak memory:
      - Async operations that have not finished (e.g. fs.readFile).
      - Timers not properly mocked (e.g. setInterval, setTimeout).
      - Keeping references to the global scope.

      at onResult (node_modules/@jest/core/build/TestScheduler.js:188:18)
          at async Promise.all (index 9)
      at async TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:260:11)
      at async runJest (node_modules/@jest/core/build/runJest.js:414:19)
      at async _run (node_modules/@jest/core/build/cli/index.js:371:7)
      at async runCLI (node_modules/@jest/core/build/cli/index.js:224:3)

 FAIL  lib/rules/value-no-vendor-prefix/__tests__/index.js
  ● Test suite failed to run

    EXPERIMENTAL FEATURE!
    Your test suite is leaking memory. Please ensure all references are cleaned.

    There is a number of things that can leak memory:
      - Async operations that have not finished (e.g. fs.readFile).
      - Timers not properly mocked (e.g. setInterval, setTimeout).
      - Keeping references to the global scope.

      at onResult (node_modules/@jest/core/build/TestScheduler.js:188:18)
          at async Promise.all (index 11)
      at async TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:260:11)
      at async runJest (node_modules/@jest/core/build/runJest.js:414:19)
      at async _run (node_modules/@jest/core/build/cli/index.js:371:7)
      at async runCLI (node_modules/@jest/core/build/cli/index.js:224:3)

 FAIL  system-tests/outputFile/outputFile.test.js
  ● Test suite failed to run

    EXPERIMENTAL FEATURE!
    Your test suite is leaking memory. Please ensure all references are cleaned.

    There is a number of things that can leak memory:
      - Async operations that have not finished (e.g. fs.readFile).
      - Timers not properly mocked (e.g. setInterval, setTimeout).
      - Keeping references to the global scope.

      at onResult (node_modules/@jest/core/build/TestScheduler.js:188:18)
          at async Promise.all (index 21)
      at async TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:260:11)
      at async runJest (node_modules/@jest/core/build/runJest.js:414:19)
      at async _run (node_modules/@jest/core/build/cli/index.js:371:7)
      at async runCLI (node_modules/@jest/core/build/cli/index.js:224:3)

 FAIL  lib/rules/max-empty-lines/__tests__/index.js
  ● Test suite failed to run

    EXPERIMENTAL FEATURE!
    Your test suite is leaking memory. Please ensure all references are cleaned.

    There is a number of things that can leak memory:
      - Async operations that have not finished (e.g. fs.readFile).
      - Timers not properly mocked (e.g. setInterval, setTimeout).
      - Keeping references to the global scope.

      at onResult (node_modules/@jest/core/build/TestScheduler.js:188:18)
          at async Promise.all (index 27)
      at async TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:260:11)
      at async runJest (node_modules/@jest/core/build/runJest.js:414:19)
      at async _run (node_modules/@jest/core/build/cli/index.js:371:7)
      at async runCLI (node_modules/@jest/core/build/cli/index.js:224:3)

 FAIL  system-tests/cli/cli.test.js
  ● Test suite failed to run

    EXPERIMENTAL FEATURE!
    Your test suite is leaking memory. Please ensure all references are cleaned.

    There is a number of things that can leak memory:
      - Async operations that have not finished (e.g. fs.readFile).
      - Timers not properly mocked (e.g. setInterval, setTimeout).
      - Keeping references to the global scope.

      at onResult (node_modules/@jest/core/build/TestScheduler.js:188:18)
          at async Promise.all (index 29)
      at async TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:260:11)
      at async runJest (node_modules/@jest/core/build/runJest.js:414:19)
      at async _run (node_modules/@jest/core/build/cli/index.js:371:7)
      at async runCLI (node_modules/@jest/core/build/cli/index.js:224:3)

 FAIL  system-tests/fix/fix.test.js
  ● Test suite failed to run

    EXPERIMENTAL FEATURE!
    Your test suite is leaking memory. Please ensure all references are cleaned.

    There is a number of things that can leak memory:
      - Async operations that have not finished (e.g. fs.readFile).
      - Timers not properly mocked (e.g. setInterval, setTimeout).
      - Keeping references to the global scope.

      at onResult (node_modules/@jest/core/build/TestScheduler.js:188:18)
          at async Promise.all (index 30)
      at async TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:260:11)
      at async runJest (node_modules/@jest/core/build/runJest.js:414:19)
      at async _run (node_modules/@jest/core/build/cli/index.js:371:7)
      at async runCLI (node_modules/@jest/core/build/cli/index.js:224:3)

 FAIL  lib/rules/property-no-vendor-prefix/__tests__/index.js
  ● Test suite failed to run

    EXPERIMENTAL FEATURE!
    Your test suite is leaking memory. Please ensure all references are cleaned.

    There is a number of things that can leak memory:
      - Async operations that have not finished (e.g. fs.readFile).
      - Timers not properly mocked (e.g. setInterval, setTimeout).
      - Keeping references to the global scope.

      at onResult (node_modules/@jest/core/build/TestScheduler.js:188:18)
          at async Promise.all (index 38)
      at async TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:260:11)
      at async runJest (node_modules/@jest/core/build/runJest.js:414:19)
      at async _run (node_modules/@jest/core/build/cli/index.js:371:7)
      at async runCLI (node_modules/@jest/core/build/cli/index.js:224:3)

 FAIL  lib/rules/selector-pseudo-element-no-unknown/__tests__/index.js
  ● Test suite failed to run

    EXPERIMENTAL FEATURE!
    Your test suite is leaking memory. Please ensure all references are cleaned.

    There is a number of things that can leak memory:
      - Async operations that have not finished (e.g. fs.readFile).
      - Timers not properly mocked (e.g. setInterval, setTimeout).
      - Keeping references to the global scope.

      at onResult (node_modules/@jest/core/build/TestScheduler.js:188:18)
          at async Promise.all (index 140)
      at async TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:260:11)
      at async runJest (node_modules/@jest/core/build/runJest.js:414:19)
      at async _run (node_modules/@jest/core/build/cli/index.js:371:7)
      at async runCLI (node_modules/@jest/core/build/cli/index.js:224:3)


Test Suites: 8 failed, 297 passed, 305 total
Tests:       3 skipped, 14858 passed, 14861 total
Snapshots:   4 passed, 4 total
Time:        76.709s
Ran all test suites.

@jeddy3
Copy link
Member

jeddy3 commented Mar 4, 2020

Is the increasing heap size a good indication that there are indeed memory leaks? If so, continuing the investigation into the leaks would be a good project for someone if they have time.

@XhmikosR
Copy link
Member

XhmikosR commented Mar 4, 2020

Is the increasing heap size a good indication that there are indeed memory leaks?

At this point, I'm not sure if the memory leaks are in tests only. It needs further investigation, for sure.

@vladanpaunovic
Copy link

vladanpaunovic commented Mar 24, 2020

It might be related to the outdated version of jsdom. There is a PR already in place jestjs/jest#9606. However, seems like maintainers are not ready to merge it yet (jestjs/jest#9606 (comment)).

@jeddy3
Copy link
Member

jeddy3 commented Jan 18, 2022

Seems to be resolved. detect-leaks shows nothing and heap size is lower:

 PASS  lib/utils/__tests__/blurInterpolation.test.js (193 MB heap size)
 PASS  lib/utils/__tests__/isCustomMediaQuery.test.js (143 MB heap size)
 PASS  lib/formatters/__tests__/jsonFormatter.test.js (117 MB heap size)
 PASS  lib/utils/__tests__/isNumbery.test.js (199 MB heap size)
 PASS  lib/__tests__/defaultSeverity.test.js (151 MB heap size)
 PASS  lib/utils/__tests__/functionArgumentsSearch.test.js (126 MB heap size)
 PASS  lib/utils/__tests__/optionsMatches.test.js (207 MB heap size)
 PASS  lib/utils/__tests__/checkInvalidCLIOptions.test.js (157 MB heap size)
 PASS  lib/utils/__tests__/hasEmptyLine.test.js (134 MB heap size)
 PASS  lib/utils/__tests__/isRangeContextMediaFeature.test.js (215 MB heap size)
 PASS  lib/utils/__tests__/isCustomProperty.test.js (164 MB heap size)
 PASS  lib/utils/__tests__/isOnlyWhitespace.test.js (138 MB heap size)
 PASS  lib/utils/__tests__/filterFilePaths.test.js (220 MB heap size)
 PASS  lib/utils/__tests__/isValidHex.test.js (171 MB heap size)

Test Suites: 1 skipped, 331 passed, 331 of 332 total
Tests:       125 skipped, 13214 passed, 13339 total
Snapshots:   13 passed, 13 total
Time:        98.876 s
Ran all test suites.
jeddy3@MacBook stylelint % 

@jeddy3 jeddy3 closed this as completed Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue is good for newcomers status: ready to implement is ready to be worked on by someone type: tests an improvement to testing
Development

No branches or pull requests

6 participants