TypeError: Cannot mix BigInt and other types, use explicit conversions

Hi everybody here I am again.
When I ran the following command ;

npm run test

I faced this following error:

$ npm run test

LBC@0.1.0 test
jest --passWithNoTests

PASS test/unit/modules/hello/assets/create_hello_asset.spec.ts (216.301 s)
FAIL test/unit/modules/hello/hello_module.spec.ts (123.5 s)
● HelloModule › encountered a declaration exception

TypeError: Cannot mix BigInt and other types, use explicit conversions

  51 | 	});
  52 | 
> 53 | 	invalidTestTransaction = testing.createTransaction({
     | 	                                 ^
  54 | 		moduleID: 2,
  55 | 		assetClass: TokenTransferAsset,
  56 | 		asset: transferAsset,

  at Object.writeUInt64 [as uint64] (node_modules/@liskhq/lisk-codec/src/varint.ts:45:46)
  at Object.writeObject (node_modules/@liskhq/lisk-codec/src/collection.ts:110:42)
  at Codec.encode (node_modules/@liskhq/lisk-codec/src/codec.ts:100:15)
  at Object.createTransaction (node_modules/lisk-framework/src/testing/create_transaction.ts:45:27)
  at Suite.<anonymous> (test/unit/modules/hello/hello_module.spec.ts:53:35)
  at Object.<anonymous> (test/unit/modules/hello/hello_module.spec.ts:22:1)

PASS test/commands/account/create.spec.ts (151.855 s)
PASS test/unit/plugins/latest_hello/latest_hello_plugin.spec.ts (41.379 s)

Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 10 todo, 19 passed, 30 total
Snapshots: 2 passed, 2 total
Time: 599.369 s
Ran all test suites.

I need somme explainations please.

Thank you.

The error comes from this line in hello_module.spec.ts
let transferAsset = { amount: "100000000", recipientAddress: account.address, data: "" };
should be
let transferAsset = { amount: BigInt('100000000'), recipientAddress: account.address, data: "" };

1 Like

Hi @przemer what you said resolced the error but another one occurred :

npm run test

LBC@0.1.0 test
jest --passWithNoTests

PASS test/unit/modules/hello/assets/create_hello_asset.spec.ts (113.215 s)
FAIL test/unit/modules/hello/hello_module.spec.ts (25.176 s)
● HelloModule › amountOfHellos › should return the absolute amount of sent hello transactions

expect(received).toEqual(expected) // deep equality

Expected: 13
Received: 0

  113 | 			);
  114 | 			const helloCounter = await helloModule.actions.amountOfHellos();
> 115 | 			expect(helloCounter).toEqual(13);
      | 			                     ^
  116 | 		});
  117 | 	});
  118 | 

  at Object.<anonymous> (test/unit/modules/hello/hello_module.spec.ts:115:25)

PASS test/commands/account/create.spec.ts (30.594 s)
PASS test/unit/plugins/latest_hello/latest_hello_plugin.spec.ts

Test Suites: 1 failed, 3 passed, 4 total
Tests: 1 failed, 10 todo, 22 passed, 33 total
Snapshots: 2 passed, 2 total
Time: 203.132 s
Ran all test suites.

Help please.