File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,11 @@ const { COUNTER } = getMiniflareBindings();
22const id = COUNTER . newUniqueId ( ) ;
33const stub = COUNTER . get ( id ) ;
44
5+ // Note this is beforeAll, not beforeEach, yet each test still has isolated storage.
6+ // See https://v2.miniflare.dev/jest.html#isolated-storage for more details.
57beforeAll ( async ( ) => {
68 const storage = await getMiniflareDurableObjectStorage ( id ) ;
7- storage . put ( "count" , 5 ) ;
9+ await storage . put ( "count" , 5 ) ;
810} ) ;
911
1012test ( "should increment count" , async ( ) => {
@@ -14,6 +16,7 @@ test("should increment count", async () => {
1416
1517test ( "should decrement count" , async ( ) => {
1618 const res = await stub . fetch ( new Request ( "http://localhost/decrement" ) ) ;
19+ // Note that the increment from above was automatically "undone", as we expect 4 not 5
1720 expect ( await res . text ( ) ) . toContain ( "⬇️ 4" ) ;
1821} ) ;
1922
You can’t perform that action at this time.
0 commit comments