clarinet icon indicating copy to clipboard operation
clarinet copied to clipboard

[BUG] clarinet test conflicting with recent deno std versions

Open hugoclrd opened this issue 3 years ago • 3 comments
trafficstars

Issue

When requiring https://deno.land/[email protected]/testing/asserts.ts (version >= 0.129) in a test file, clarinet test throws the following error:

error: TS2352 [ERROR]: Conversion of type 'T' to type 'string' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
          ? diffstr(actual as string, expected as string)
                                      ~~~~~~~~~~~~~~~~~~
    at https://deno.land/[email protected]/testing/asserts.ts:357:39

Step to reproduce

Simply import deno's assert in an empty test file:

import { assertEquals } from 'https://deno.land/[email protected]/testing/asserts.ts';

Run clarinet test

Workaround

Downgrade to [email protected] or lower

hugoclrd avatar Mar 22 '22 18:03 hugoclrd

Confirmed also on my local. In my case, I can use up to [email protected]. Here's a repro, note that this uses [email protected]:

import { Clarinet, Tx, Chain, Account, types }
  from 'https://deno.land/x/[email protected]/index.ts';

import { assertEquals }
  from 'https://deno.land/[email protected]/testing/asserts.ts';

Clarinet.test({
    name: "Ensure that <...>",
    async fn(chain: Chain, accounts: Map<string, Account>) {
        let block = chain.mineBlock([
            /* 
             * Add transactions with: 
             * Tx.contractCall(...)
            */
        ]);
        assertEquals(block.receipts.length, 0);
        assertEquals(block.height, 2);

        block = chain.mineBlock([
            /* 
             * Add transactions with: 
             * Tx.contractCall(...)
            */
        ]);
        assertEquals(block.receipts.length, 0);
        assertEquals(block.height, 3);
    },
});

Output:

* Ensure that <...> ... ok (326ms)

Now, if I bump the version, to > [email protected], e.g. [email protected]

diff --git a/foo_test.ts b/foo_test.ts
index b501bb7..942ad73 100644
--- a/foo_test.ts
+++ b/foo_test.ts
@@ -2,7 +2,7 @@ import { Clarinet, Tx, Chain, Account, types }
   from 'https://deno.land/x/[email protected]/index.ts';

 import { assertEquals }
-  from 'https://deno.land/[email protected]/testing/asserts.ts';
+  from 'https://deno.land/[email protected]/testing/asserts.ts';

 Clarinet.test({
     name: "Ensure that <...>",

Output:

Uncaught SyntaxError: Unexpected identifier
  override name = "AssertionError";
           ~~~~
    at <anonymous> (https://deno.land/[email protected]/testing/asserts.ts:20:12)

moodmosaic avatar Mar 23 '22 14:03 moodmosaic

Perhaps this can be worked together with https://github.com/hirosystems/clarinet/issues/393.

moodmosaic avatar Jun 14 '22 07:06 moodmosaic

To be addressed with https://github.com/hirosystems/clarinet/pull/511

lgalabru avatar Aug 08 '22 00:08 lgalabru

Fixed with 1.0 and #511 👍 Closing since the release is on the way

hugoclrd avatar Oct 06 '22 16:10 hugoclrd