aws / aws/aws-appsync-community

import { util } from '@aws-appsync/utils' is empty object

Open
#363 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
HTML
Stars
507
Forks
37
PR merge metrics
No merged PRs in 30d

Description

I'm having some trouble using the `@aws-appsync/utils` (v1.8.0) in my Vitest tests. Given the following test script `util` is equal to `{}`;

```ts

import { util } from '@aws-appsync/utils';
import { describe, expect, test } from 'vitest';

describe('Use AppSync @aws-appsync/utils', () => {

test('util should not be empty', () => {
console.log(util); // prints {}
expect(util).not.toMatchObject({});
});

test('util.autoId() should be a function', () => {

expect(util?.autoId).toBeTypeOf('function');

const id = util.autoId();

expect(id).toBeDefined();
});

test('util.time.nowISO8601() should produce a date', () => {

expect(util.time.nowISO8601).toBeTypeOf('function');

const t = util.time.nowISO8601();

console.log(`Generated time: ${t}`);

expect(t).toBeDefined();
});

});

```

Importing `Context` from `@aws-appsync/utils` works as expected.

~~I've placed a full, self contained example [here](https://github.com/naedx/amplify-playground/tree/dev/projects/amplify-appsync-vitest).~~

Contributor guide

Open the contributing guide

Research direction

Start with the Vitest reproduction shown in the issue and inspect the @aws-appsync/utils import entry point, comparing the util export with the working Context import. Confirm the behavior against version 1.8.0; done means util is populated and util.autoId() and util.time.nowISO8601() are callable in the test.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
backend-api-design, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.