Jest Your are trying to import a file after the jest environment has been torn down - import

when i import a file into my test file i have the following error :
ReferenceError: You are trying to import a file after the Jest environment has been torn down. From __test__/C_Mail.test.js.
at BufferListStream.Readable (node_modules/readable-stream/lib/_stream_readable.js:170:22)
at BufferListStream.Duplex (node_modules/readable-stream/lib/_stream_duplex.js:60:12)
at new BufferListStream (node_modules/bl/bl.js:33:16)
at new IncomingMessageStream (node_modules/tedious/lib/incoming-message-stream.js:34:15)
at new MessageIO (node_modules/tedious/lib/message-io.js:41:34)
C:\Users\anisb\OneDrive\Bureau\alertemail\projetHexakey\node_modules\readable-stream\lib\_stream_readable.js:174
var isDuplex = this instanceof Duplex;
^
TypeError: Right-hand side of 'instanceof' is not callable
at BufferListStream.Readable (C:\Users\anisb\OneDrive\Bureau\alertemail\projetHexakey\node_modules\readable-stream\lib\_stream_readable.js:174:23)
at BufferListStream.Duplex (C:\Users\anisb\OneDrive\Bureau\alertemail\projetHexakey\node_modules\readable-stream\lib\_stream_duplex.js:60:12)
at new BufferListStream (C:\Users\anisb\OneDrive\Bureau\alertemail\projetHexakey\node_modules\bl\bl.js:33:16)
at new IncomingMessageStream (C:\Users\anisb\OneDrive\Bureau\alertemail\projetHexakey\node_modules\tedious\lib\incoming-message-stream.js:34:15)
at new MessageIO (C:\Users\anisb\OneDrive\Bureau\alertemail\projetHexakey\node_modules\tedious\lib\message-io.js:41:34)
at C:\Users\anisb\OneDrive\Bureau\alertemail\projetHexakey\node_modules\tedious\lib\connection.js:1442:24
at Socket.onConnect (C:\Users\anisb\OneDrive\Bureau\alertemail\projetHexakey\node_modules\tedious\lib\connector.js:156:7)
at Socket.emit (node:events:526:28)
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1143:10)
Can someone help me ?
I tried to solve using jest.UseFakeTimers() but not useful for me, it tried everything on the web but i didn't found the solution
Thanks everybody

Related

setting bash editor as vscode throw error node:internal/modules/cjs/loader:990

I am trying to set up visual studio code as default editor on git bash. However, I keep facing the following issue.
node:internal/modules/cjs/loader:990
throw err;
^
Error: Cannot find module 'C:\Users\username\anaconda3\Library\c\Users\username\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
I've tried to reinstall vscode, git and nodejs. But it doesn't help.
Also tried editing the env path to no avail.
The error seems to lie in the module path itself which resolves to duplicated "c\Users\username..."
Appreciate any help here. Thanks!
UPDATE
I manage to dig deeper and found out that it is due to these particular lines of code that is causing the issue.
elif [ -x "$(command -v cygpath)" ]; then <-- THIS LINE
CLI=$(cygpath -m "$VSCODE_PATH/resources/app/out/cli.js")
They can be found in C:\Users\username\AppData\Local\Programs\Microsoft VS Code\bin\code.
Apparently, code is referencing to the cygpath that was installed by anaconda3 and hence ran the if statement. If I comment these 2 lines out to prevent cygpath from running, I am able to open vscode via bash with no issue. However, I don't think this is the long term solution.
Appreciate any advice. Thanks!

vscode python lint problem at the first column of first line

I have python modules that I run in VSCode for development.
And everything works fine until today VSCode suddenly said that one of the module had some binding problem and made the file name tab red.
VSCode the problem occurs in the first character of the first line which is the following standard line at every module of my program.
from __future__ import print_function # (at top of module)
But strangely VSCode did not raise the same problem for other module that starts with the same line.
The problem message is like this.
An internal error occurred while binding file "aModule.py": Error: Debug Failure. createKeyForReference received unexpected expression type
at createKeyForReference (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\codeFlowTypes.ts:240:9)
at createKeyForReference (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\codeFlowTypes.ts:218:25)
at C.visitAssignment (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\binder.ts:849:50)
at C.visitNode (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\parseTreeWalker.ts:132:29)
at C.walk (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\parseTreeWalker.ts:98:37)
at forEach (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\parseTreeWalker.ts:107:22)
at Array.forEach (<anonymous>)
at C.walkMultiple (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\parseTreeWalker.ts:105:15)
at C.walk (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\parseTreeWalker.ts:100:18)
at C._walkStatementsAndReportUnreachable (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\binder.ts:2583:22)
at C.visitSuite (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\binder.ts:345:14)
at C.visitNode (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\parseTreeWalker.ts:330:29)
at C.walk (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\parseTreeWalker.ts:98:37)
at callback (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\binder.ts:1290:22)
at C._trackCodeFlowExpressions (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\binder.ts:3236:9)
at C.visitIf (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\binder.ts:1265:48)
at C.visitNode (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\parseTreeWalker.ts:184:29)
at C.walk (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\parseTreeWalker.ts:98:37)
at C._walkStatementsAndReportUnreachable (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\binder.ts:2583:22)
at C.visitSuite (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\binder.ts:345:14)
at C.visitNode (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\parseTreeWalker.ts:330:29)
at C.walk (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\parseTreeWalker.ts:98:37)
at Object.callback (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\binder.ts:545:22)
at C._bindDeferred (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\binder.ts:4140:22)
at C.bindModule (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\binder.ts:298:14)
at callback (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\sourceFile.ts:1197:28)
at s.timeOperation (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\common\timing.ts:40:20)
at callback (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\sourceFile.ts:1184:38)
at t.LogTracker.log (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\common\logTracker.ts:43:20)
at t.SourceFile.bind (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\sourceFile.ts:1181:33)
at O._bindFile (c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\program.ts:931:34)
at c:\Users\Farn\.vscode\extensions\ms-python.vscode-pylance-2022.7.40\dist\pyright-internal\src\analyzer\program.ts:1051:18
Can someone help?
Thanks
Farn

VSCode : --jsx flag interferes with auto import suggestions

I have a typescript-react project.
When I include the jsx flag in the tsconfig.json file, it messes up the auto import suggestions.
If I don't include the jsx flag, auto import suggestions work, but I see errors that I can't use JSX without the --jsx flag as expected.
I have tried playing around with the tsconfig options, but sadly have had no luck.
Have I stumbled upon a VS Code bug or am I missing something very basic?
The relevant tsserver.log entry:
Debug Failure.
Error: Debug Failure.
at Object.assertDefined (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:2101:24)
at getDefaultExportInfoWorker (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:118907:80)
at getDefaultLikeExportInfo (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:118867:24)
at c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:118850:35
at c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:119023:21
at forEachExternalModule (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:119036:21)
at forEachExternalModuleToImportFrom (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:119021:13)
at getExportInfos (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:118848:13)
at getFixesInfoForNonUMDImport (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:118834:57)
at getFixesInfo (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:118772:50)
at Object.getCodeActions (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:118533:28)
at c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:115852:121
at Object.flatMap (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:583:25)
at Object.getFixes (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:115852:23)
at c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:125866:35
at Object.flatMap (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:583:25)
at Object.getCodeFixesAtPosition (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:125864:23)
at IOSession.Session.getCodeFixes (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:135063:64)
at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:133850:61)
at c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:135256:88
at IOSession.Session.executeWithRequestId (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:135247:28)
at IOSession.Session.executeCommand (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:135256:33)
at IOSession.Session.onMessage (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:135279:35)
at Interface.<anonymous> (c:\Codebase\webui\node_modules\typescript\lib\tsserver.js:136594:27)
at Interface.emit (events.js:182:13)
at Interface._onLine (readline.js:290:10)
at Interface._normalWrite (readline.js:433:12)
at Socket.ondata (readline.js:149:10)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
VS Code version: 1.38.1
Typescript version: 3.6.3
P.S. Copy-pasting or manually writing imports works, but I believe the IDEs have made us lazy on that front. :)

TypeError: Cannot read property 'call' of undefined

So basically I am just getting started with Truffle and I have created my first Solidity code, which looks like this:
pragma solidity ^0.4.4;
contract HelloWorld
{
function SayHello() internal pure returns (string)
{
return ("Hello World!");
}
}
I then opened Powershell and ran the following command: testrpc Than I compiled and migrated my code using "truffle" compile and "truffle migrate"
The problems started occurring when I opened "truffle console" and did this, giving me an error at the end:
PS C:\Users**\MetaCoin> truffle console
truffle(development)> var hw
undefined
truffle(development)> HelloWorld.deployed().then(function(deployed){hw=deployed});
undefined
truffle(development)> hw.SayHello.call()
TypeError: Cannot read property 'call' of undefined
truffle(development)>
Can someone help me with this? Thanks.

Vue import failing

I've created a vue application scaffolded from the vue cli. Almost everything is reacting as expected with my app except for an issue with import.
The following works fine:
import Vuex from 'vuex';
but, this throws errors:
import { VuetronVue, VuetronVuex } from 'vuetron';
vue.use(VuetronVue);
Linting error:
"export 'VuetronVue' was not found in 'vuetron'
and Console error:
Uncaught TypeError: Cannot read property 'install' of undefined
Changing the code to:
import vuetron from 'vuetron'
vue.use(vuetron.VuetronVue);
resolves the issue...
This original code was taken directly from the Vuetron documentation. Does anyone have a suggestion as to why the ES6 notation would cause an issue?
This seems to be because
vuetron/packages/vuetron-plugins/index.js
only exports the default object:
import VuetronVue from './vuetron-vue';
import VuetronVuex from './vuetron-vuex';
export default {
VuetronVue,
VuetronVuex
};
For named imports as stated in the docs you would need a named export.