Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Unit Test Case01.04 #9

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Fix Unit Test Case01.04 #9

wants to merge 11 commits into from

Conversation

sophiadt
Copy link

@sophiadt sophiadt commented Nov 21, 2024

Fix Unit Test Case01.04

test Case0.104 gave Uncaught ReferenceError: require is not defined

This is because require is a Node.js function but the package type is defined as module in package.json, so we have to use ES modules like import and export. But then Jest wouldn't be able to parse the file so JSResolverOCHTTPSTemplate, output.resolver.graphql.cjs, testLib were changed to .mjs files to mark those files as ES modules.

Changes:

  • changed JSResolverOCHTTPSTemplate, output.resolver.graphql.cjs, testLib to .mjs
  • changed imports to
import pkg from './output.resolver.graphql.js';
const {resolveGraphDBQueryFromAppSyncEvent, refactorGremlinqueryOutput} = pkg;
  • added export default { resolveGraphDBQueryFromAppSyncEvent, resolveGraphDBQueryFromApolloQueryEvent } so it works with the pkg import
  • added "type": "module", in the package.json files for Lambda4AppSyncHTTP and Lambda4AppSyncSDK in the templates folder

@sophiadt sophiadt marked this pull request as ready for review November 27, 2024 17:58
test/testLib.mjs Outdated Show resolved Hide resolved
test/testLib.mjs Outdated Show resolved Hide resolved
test/testLib.mjs Outdated Show resolved Hide resolved
@@ -8,6 +8,7 @@
},
"author": "",
"license": "ISC",
"type": "module",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kris mentioned that you should be able to revert the renaming of js files to mjs can be potentially be reverted after this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants