Open anilhelvaci opened 1 year ago
When I agoric init
a new project, the contract/test/test-contract.js
file starts with:
import { test } from './prepare-test-env-ava.js';
where ./prepare-test-env-ava.js
contains:
/**
* Like prepare-test-env but also sets up ses-ava and provides
* the ses-ava `test` function to be used as if it is the ava
* `test` function.
*/
import '@endo/init/pre-bundle-source.js';
import '@agoric/zoe/tools/prepare-test-env.js';
// eslint-disable-next-line import/no-unresolved -- https://github.com/avajs/ava/issues/2951
import rawTest from 'ava';
// XXX wrapTest not working https://github.com/endojs/endo/issues/1235
// import { wrapTest } from '@endo/ses-ava';
export const test = rawTest;
Try that?
So import { wrapTest } from '@endo/ses-ava';
is not mandatory? @dckc
I observed that wrapTest
fails in my dapp but I'm able to run tests that use it. What could be causing that?
What is the best way to setup test environment with
ses
andava
?When I was trying to find an answer to this question I've come across two main ways to setup ava;
I also saw a
prepare-test-env-ava.js
at the notifier package which is similar to the one from zoe. I'll drop it's content anyway.Environement
fedf049435d7307311219fbab1b2b342ec6acce8
Problem
I can only make my tests work following the first approach but I'm concerned that I might be missing somethings by not making the tests work with approach two and it's sub-approach.
In order to narrow down the problem I've prepared a small test with multiple ava environments. The actual code is here.
This is the command I use to run the test;
Below are the results;
When we fetch initiate test environment importing from
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
the console output;When we fetch initiate test environment importing from
import { test } from '@agoric/notifier/test/prepare-test-env-ava.js';
the console output;When I copy/paste the contents of prepare-test-env-ava.js to a file in the same directory and import it like this
import { test } from './prepare-test-env-ava.js';
the console output is;The console output;
Seems to be working.
It's seems very strange to me that I get different outputs every time I use different imports. What do you think? @dckc