Using `require` to inject file contents into JS files causes issues with unit tests
See original GitHub issueWe cannot write unit tests for some files if using code as follows:
const addRunCellHook = require('../../pythonFiles/vscode_datascience_helpers/kernel/addRunCellHook.py');
- We might want to consider removing such webpack specific code from our code and use some other way to inject the file contents.
- Or we need way another way to write unit tests for such files.
- Or we could have a simple provider that provides the contents of these files.
- We end up duplicating the files (its in the source code as well as vsix)
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Require file on runtime & unit test issue - Stack Overflow
I use require. js to load files at runtime like following This is working as expected when I run the file in the...
Read more >Same file unit tests · Issue #4316 · facebook/jest - GitHub
If unit tests are written in the same file as the source code, jest has the following problems: Assume A.js and B.js both...
Read more >How to Write File-Based JavaScript Tests With Real Files
Hey guys, this post is about writing tests for projects that access the file system by reading and writing files to disk.
Read more >Unit Tests with JavaScript - Patrick Schadler Engineering
In this blog post we are going to create a brand-new NodeJS project with Jasmine to run some unit tests with JavaScript.
Read more >4. Unit Tests - Testable JavaScript [Book] - O'Reilly
Any extra code may influence the test or the code being tested, and can cause problems. Typically, unit tests exercise a single method....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hmm, I think the file system could read it from the extension URI. I don’t think these need to be embedded.
@sadasant’s other fix in this area should be applicable.