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 ENOENT error for Jest test in function-no-unknown #5904
Comments
function-no-unknown
rule can break
I've look around a bit and I found that it might also be related to
Issue following jest ESM support |
The |
@100terres I've opened a pull request #5906 that may fix your problem. Can you try it, please? - "stylelint": "^14.5.0",
+ "stylelint": "github:stylelint/stylelint#issue-5904", |
Sorry, PR #5906 doesn't work. 😢 |
@100terres I've opened PR #5916 that no longer uses - "stylelint": "^14.5.0",
+ "stylelint": "github:stylelint/stylelint#bump-css-functions-list", |
Hi @ybiquitous thank you for your time! 🙂 I've just tested it here and know it's giving me this error. I didn't had the time to investigate if I need to change something in my config (with
Here is the result of the CI https://app.circleci.com/pipelines/github/react-forked/dnd/232/workflows/bf31edb7-16e2-4c43-9835-0271ab13ef75/jobs/1349 And now event if I disable the
|
@100terres Thanks for the detailed reproduction. I'm not sure why |
@100terres The problem seems due to diff --git a/jest.config.js b/jest.config.js
index 08a90c82..52634cf4 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -12,4 +12,5 @@ module.exports = {
'jest-watch-typeahead/testname',
],
verbose: true,
+ testEnvironment: 'node',
}; $ npx jest test/unit/view/style-marshal/get-styles.spec.ts
PASS test/unit/view/style-marshal/get-styles.spec.ts
✓ should generate valid always styles (117 ms)
✓ should generate valid resting styles (5 ms)
✓ should generate valid dragging styles (6 ms)
✓ should generate valid dropAnimating styles (3 ms)
✓ should generate valid userCancel styles (1 ms)
Test Suites: 1 passed, 1 total
Tests: 5 passed, 5 total
Snapshots: 0 total
Time: 0.946 s, estimated 2 s
Ran all test suites matching /test\/unit\/view\/style-marshal\/get-styles.spec.ts/i. EDIT: Tested on hello-pangea/dnd@b16f775 |
'use strict';
var url = require('url');
/**
* Path to CSS functions list JSON file.
*/
const location = url.fileURLToPath(new url.URL('index.json', (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.js', document.baseURI).href))));
module.exports = location;
//# sourceMappingURL=index.js.map I try embedding the debug code into the above file: var url = require('url');
+console.log('document:', document)
+console.log('document.currentScript:', document.currentScript)
+console.log('document.baseURI:', document.baseURI)
/**
* Path to CSS functions list JSON file.
*/ Then, run the failed test: $ npx jest test/unit/view/style-marshal/get-styles.spec.ts
console.log
document: Document {
location: [Getter/Setter],
[Symbol(DOM SymbolTree)]: SymbolTreeNode {
parent: null,
previousSibling: null,
nextSibling: null,
firstChild: null,
lastChild: null,
childrenVersion: 0,
childIndexCachedUpTo: null,
cachedIndex: -1,
cachedIndexVersion: NaN
}
}
at Object.<anonymous> (node_modules/css-functions-list/cjs/index.js:4:9)
console.log
document.currentScript: null
at Object.<anonymous> (node_modules/css-functions-list/index.js:3:1)
console.log
document.baseURI: http://localhost/
at Object.<anonymous> (node_modules/css-functions-list/index.js:4:1)
FAIL test/unit/view/style-marshal/get-styles.spec.ts
... Unexpectedly, |
Hi @ybiquitous thank you a lot for taking the time to investigate this futher! 🙂 I've just tested it and has you mention the test works in the It feels like that inside a |
Also |
@100terres Thanks for sharing the knowledge. 👍🏼 |
What steps are needed to reproduce the bug?
I've documented the issue on a library used by
stylelint
require('css-functions-list')
returns"/index.json"
niksy/css-functions-list#2 (comment)Use the stylelint with the node API
Using
stylelint-config-recommended@v7.0.0
It's running in a
jest@v26.6.3
testUsing
node@v14.18.2
EDIT: In a
TypeScript@4.5.5
/ babel environmentWhen running this the
function-no-unknown
rule throws this errorHere is where it fails https://github.com/react-forked/dnd/blob/e18cfa53c3f6bb8f085137c934a4a0d9b8332671/test/unit/view/style-marshal/get-styles.spec.ts
Here is the error in CircleCI
https://app.circleci.com/pipelines/github/react-forked/dnd/229/workflows/9d30597b-ac76-4548-b2cb-3416ab0a03fe/jobs/1331
What Stylelint configuration is needed to reproduce the bug?
How did you run Stylelint?
Node
stylelint.lint(...)
Which version of Stylelint are you using?
14.5.0
What did you expect to happen?
To not throw an error
What actually happened?
It throws this error
Does the bug relate to non-standard syntax?
Nop
Proposal to fix the bug
As suggested here I've made it work by using
path.resolve
here in this lib and directly using the return of therequire("css-functions-list")
here without using thenew URL
.The text was updated successfully, but these errors were encountered: