Error:
/Users/pulkitgupta/Desktop/OpenSource/CircuitVerse/jest.setup.js:4
import Array from './simulator/src/arrayHelpers';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1773:14)
at async TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:317:13)
at async runJest (node_modules/@jest/core/build/runJest.js:407:19)
Solution:
using babel-preset-env
npm i @babel/preset-env
Details:
/Users/pulkitgupta/Desktop/OpenSource/CircuitVerse/node_modules/codemirror/lib/codemirror.css:3
.CodeMirror {
^
SyntaxError: Unexpected token '.'
3 |
4 | import CodeMirror from 'codemirror/lib/codemirror.js';
> 5 | import 'codemirror/lib/codemirror.css';
| ^
6 |
7 | // Importing CodeMirror themes
8 | import 'codemirror/theme/3024-day.css';
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1773:14)
at Object.<anonymous> (simulator/src/Verilog2CV.js:5:1)
Solution: using identity-obj-proxy
npm i identity-obj-proxy
Error:
● Validation Error:
Test environment jest-environment-jsdom cannot be found. Make sure the testEnvironment configuration option points to an existing node module.
Configuration Documentation:
https://jestjs.io/docs/configuration
As of Jest 28 "jest-environment-jsdom" is no longer shipped by default, make sure to install it separately.
Solution: npm install --save-dev jest-environment-jsdom
Error:
● Test suite failed to run
Cannot find module 'bootstrap-input-spinner/src/bootstrap-input-spinner' from 'jest.setup.js'
12 | window.userSignedIn = true;
13 | window.embed = false;
> 14 |
| ^
15 | import Array from './simulator/src/arrayHelpers';
16 |
17 | window['Array'] = Array;
at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:491:11)
at Object.<anonymous> (jest.setup.js:14:23)
FAIL simulator/spec/gates/nandGate.spec.js
● Test suite failed to run
TypeError: $(...).inputSpinner is not a function
450 | });
451 |
> 452 | $(".moduleProperty input[type='number']").inputSpinner();
| ^
453 | }
454 |
455 | /**
Solution: npm i bootstrap-input-spinner
Error:
● Simulator Gates Testing › load circuitData
expect(received).not.toThrow()
Error name: "TypeError"
Error message: "Cannot read property 'beginPath' of null"
299 | x2 *= globalScope.scale;
300 | y2 *= globalScope.scale;
> 301 | ctx.beginPath();
| ^
302 | ctx.strokeStyle = color;
303 | ctx.lineCap = 'round';
304 | ctx.lineWidth = correctWidth(width);//* globalScope.scale;
at beginPath (simulator/src/canvasApi.js:301:9)
at Wire.draw (simulator/src/wire.js:142:9)
at draw (simulator/src/engine.js:260:91)
at renderCanvas (simulator/src/engine.js:510:9)
at load (simulator/src/data/load.js:211:9)
at simulator/spec/gates.spec.js:20:22
at Object.<anonymous> (node_modules/expect/build/toThrowMatchers.js:83:11)
at Object.throwingMatcher [as toThrow] (node_modules/expect/build/index.js:342:21)
at Object.toThrow (simulator/spec/gates.spec.js:20:45)
at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:317:13)
at runJest (node_modules/@jest/core/build/runJest.js:407:19)
at _run10000 (node_modules/@jest/core/build/cli/index.js:338:7)
at runCLI (node_modules/@jest/core/build/cli/index.js:190:3)
18 |
19 | test('load circuitData', () => {
> 20 | expect(() => load(circuitData)).not.toThrow();
| ^
21 | });
22 |
23 | test('AND gate testing', () => {
at Object.toThrow (simulator/spec/gates.spec.js:20:45)
at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:317:13)
at runJest (node_modules/@jest/core/build/runJest.js:407:19)
at _run10000 (node_modules/@jest/core/build/cli/index.js:338:7)
at runCLI (node_modules/@jest/core/build/cli/index.js:190:3)
Solution: using canvas node module
npm i canvas