near / near-workspaces-js

Write tests once, run them both on NEAR TestNet and a controlled NEAR Sandbox local environment
https://near.github.io/near-workspaces-js/
GNU General Public License v3.0
42 stars 21 forks source link

Clarification on the using other testing libraries comment #104

Closed the-mercenaries-ltd closed 2 years ago

the-mercenaries-ltd commented 2 years ago

Hi team,

In the docs you say; If you prefer a testing library other than AVA, you can use near-workspaces-js directly.

I'd love a slight expansion on the steps one would do for this.

I have managed to get the Workspace.init command to work, see my gist here: https://gist.github.com/jackrobsonalpha/7a33d41951c8d8915b27f335f4270f80

And I've got it to wait for the workspace to load before it continues.

However it still fails at workspace.test( giving the error:


    TypeError: workspace.test is not a function```

I know the  near-workspace-js Workspace class does not have a test function.

And I can't work out how Ava is doing this. 

Could you explain how to get my next workspace.test (or another function that uses the workspace) to work?

Code is good but even just an explanation would really help.

Regards,
Jack
Amacc commented 2 years ago

As for the how is Ava doing this it looks like the test function is here:

https://github.com/near/workspaces-js/blob/c6a6261873aee76930deff3053f9582595b528fb/packages/ava/src/index.ts#L110

But to implement your own just require your testing tool of choice and pass the required arguments in place of the workstation.test calls. Hope that helps.

the-mercenaries-ltd commented 2 years ago

Ah, I did not realise ava was a testing framework.

I thought it was a Nears solution to get mocha tests of sorts.

Thank you for the clarification.

Using your insights I can see what I need todo.

Might be able to use the Workspace fork function to create a function like the test function.

On Fri, 14 Jan 2022, 01:11 Amacc, @.***> wrote:

As for the how is Ava doing this it looks like the test function is here:

https://github.com/near/workspaces-js/blob/c6a6261873aee76930deff3053f9582595b528fb/packages/ava/src/index.ts#L110

But to implement your own just require your testing tool of choice and pass the required arguments in place of the workstation.test calls. Hope that helps.

— Reply to this email directly, view it on GitHub https://github.com/near/workspaces-js/issues/104#issuecomment-1012659421, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVFIEQ7SDLITDNFXKO2IO6LUV5Z4BANCNFSM5L5LLJ3Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>