Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HELP: Test using import from @graphprotocol/graph-ts #408

Open
NanezX opened this issue Nov 14, 2023 · 1 comment
Open

HELP: Test using import from @graphprotocol/graph-ts #408

NanezX opened this issue Nov 14, 2023 · 1 comment

Comments

@NanezX
Copy link

NanezX commented Nov 14, 2023

Hello guys, hope you all good.

I'm kind of new using AssemblyScript. I use it mainly for building subgraph with the @graphprotocol/graph-ts lib, which is ok. Currently I'm working on a repository and it have some utils that I want to test. They are mainly methods to convert from like a BigInt to Bytes, handle strings, or even some other utilities.

The issue is that I'm getting an error when running the tests with imports: TypeError: WebAssembly.instantiate(): Import #1 module="conversion" error: module is not an object or function.

The code that I have is:

// assembly/index.ts
import { Bytes } from "@graphprotocol/graph-ts";

export function get_empty_byte(): Bytes {
  return Bytes.empty();
}

And the test file:

// assembly/__tests__/example.spec.ts
import { get_empty_byte } from "..";

describe("example", () => {
  it("test get_empty_byte", () => {
    let resp = get_empty_byte();
    log("get_empty_byte");
  });
});

My as-pect.asconfig.json and as-pect.config.js are exactly how the package generate them, but I also tried adding the import to the instantiate async function. I don't understand well this part, but didn't work since I got TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts".

So, I really think that I'm doing something wrong but I can't see where or how make it work. To me make senses that it's possible to do this kind of tests, but I didn't find any example with imports (atm).

My dependencies are:

"@as-pect/cli": "^8.1.0",
"assemblyscript": "^0.27.17",
"@graphprotocol/graph-ts": "^0.31.0"

If someone could help me it will be awesome, I hope it's enough information for this. Thanks for taking time on read this and help :)

@willemneal
Copy link
Collaborator

Hey @NanezX, it's been a long time since I've been involved, but @jtenner, might be able to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants