Hello, I’m new to Flow and I’m trying to write a very simple test.
But when I try to use const Alice = await getAccountAddress('alice')
I’m getting the error: "TypeError: Cannot destructure property ‘events’ of ‘e’ as it is null"
My test is very simple. So I’m probably missing something but I don’t know what
Here is my test:
import path from "path";
import { emulator, init, getAccountAddress } from "flow-js-testing";
// Increase timeout if your tests failing due to timeout
jest.setTimeout(10000);
describe("Token", () => {
beforeEach(async () => {
const basePath = path.resolve(__dirname, "../cadence");
// You can specify different port to parallelize execution of describe blocks
const port = 8888;
// Setting logging flag to true will pipe emulator output to console
const logging = false;
await init(basePath, { port });
return emulator.start(port, logging);
});
// Stop emulator, so it could be restarted
afterEach(async () => {
return emulator.stop();
})
test("Alice should exist", async () => {
const Alice = await getAccountAddress('alice')
expect(Alice).toBeDefined()
})
});
The error:
› Alice should exist
TypeError: Cannot destructure property 'events' of 'e' as it is null.
23 |
24 | test("Alice should exist", async () => {
> 25 | const Alice = await getAccountAddress('alice')
| ^
26 | expect(Alice).toBeDefined()
27 | })
28 | });
at events (node_modules/flow-js-testing/src/account.js:64:19)
at Object.<anonymous> (cadence/tests/ZooToken.test.ts:25:23)