question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using `require` to inject file contents into JS files causes issues with unit tests

See original GitHub issue

We 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:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rchiodocommented, May 23, 2022

Hmm, I think the file system could read it from the extension URI. I don’t think these need to be embedded.

0reactions
rchiodocommented, May 26, 2022

@sadasant’s other fix in this area should be applicable.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found