codesandbox-client icon indicating copy to clipboard operation
codesandbox-client copied to clipboard

fs.readFileSync() causes tests to hang

Open courtneypattison opened this issue 2 years ago • 0 comments

🐛 bug report

Preflight Checklist

  • [x] I have read the Contributing Guidelines for this project.
  • [x] I agree to follow the Code of Conduct that this project adheres to.
  • [x] I have searched the issue tracker for an issue that matches the one I want to file, without success.

Description of the problem

Cannot use fs.readFileSync() in tests

How has this issue affected you? What are you trying to accomplish?

I would like to write unit tests for a Vanilla Javascript project. To do that I need to read the index.html file into my test file.

To Reproduce

import fs from "fs";
const html = fs.readFileSync("index.html", "utf-8");

In src/index.tests.js causes the tests to hang. In src/index.js it works just fine.

Link to sandbox: link

Your Environment

Software Name/Version
Сodesandbox Browser
Browser Chrome Version 114.0.5735.198 (Official Build) (arm64)
Operating System macOs Ventura 13.4.1

courtneypattison avatar Jul 27 '23 18:07 courtneypattison