jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
44.27k stars 6.46k forks source link

[Bug]: Path in bin/jest.js file crash when there's a single "Single quote" in the path #15124

Closed gorritocodes closed 5 months ago

gorritocodes commented 5 months ago

Version

29.7.0

Steps to reproduce

when I run npm jest, in node_modules/jest/bin/ the file jest.js is generated.

the file in my case is located in :C:\Users**Gorrito's Laptop**\Documents\Development\Jest Tutorials\JavaScript Testing with Jest - Crash Course\node_modules\jest\bin\jest.js

but as my user has a single quote it crashes.

The file looks like this:

#!/usr/bin/env node
/* build-hook-start *//*00001*/try { require('c:\\Users\\Gorrito's Laptop\\.vscode\\extensions\\wallabyjs.console-ninja-1.0.324\\out\\buildHook\\index.js').default({tool: 'jest'}); } catch(cjsError) { try { import('file:///c:/Users/Gorrito's%20Laptop/.vscode/extensions/wallabyjs.console-ninja-1.0.324/out/buildHook/index.js').then(m => m.default.default({tool: 'jest'})).catch(esmError => {}) } catch(esmError) {}}/* build-hook-end */

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const importLocal = require('import-local');

if (!importLocal(__filename)) {
  require('jest-cli/bin/jest');
}

I have tried to use template strings and double quotes to escape the bug manually, but it leads to a waterfall of crashing systems.

Expected behavior

I expected to execute as it does on my other machine. The problem it's not in my repo, but in the relationship the repo has with my computer's name.

Actual behavior

My computer name happens to be an edge case in the ways the routes are set in Jest, and prevents the normal execution of the software

Additional context

No response

Environment

No "jest." preset found.
PS C:\Users\Gorrito's Laptop\Documents\Development\Jest Tutorials\JavaScript Testing with Jest - Crash Course>

Processor   Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz   2.90 GHz
Installed RAM   12.0 GB
System type 64-bit operating system, x64-based processor
mrazauskas commented 5 months ago

You should report this issue to wallabyjs. The second line of the binary is added by them. This is not the original code shipped by Jest.

gorritocodes commented 5 months ago

Oh, Thank you! I'll take The issue there!

github-actions[bot] commented 4 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.