Error: Webpack Compilation Error ./node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/signature-v4/dist-es/getCanonicalHeaders.js 10:30 Module parse failed: Unexpected token (10:30) #24521
Replies: 4 comments 5 replies
-
Do you have webpack installed or are you using the default one we ship with Cypress? I think we are still shipping webpack 4, which doesn't know about the If you install a more recent version of webpack, it should handle that. It also might depend on your If you can provide a minimal reproduction, I could help fix it up, too. |
Beta Was this translation helpful? Give feedback.
-
facing the same issue when importing |
Beta Was this translation helpful? Give feedback.
-
Hi I am seeing this same issue.
| PROXY_HEADER_PATTERN.test(canonicalHeaderName) || |
Beta Was this translation helpful? Give feedback.
-
@glamanna-motional @sikander804 I reproduced this by making a new project and doing require('@aws-sdk/client-s3') in my It didn't work. I then followed the instruction here https://www.npmjs.com/package/@cypress/webpack-preprocessor. I installed the dependencies it told me to. {
"name": "aws-cypress",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@aws-sdk/client-s3": "^3.226.0",
"@babel/core": "^7.20.5",
"@babel/preset-env": "^7.20.2",
"@cypress/webpack-preprocessor": "^5.15.6",
"babel-loader": "^9.1.0",
"cypress": "^12.0.2"
},
"dependencies": {
"webpack": "^5.75.0"
}
} I added the preprocessor in const { defineConfig } = require("cypress");
const preprocessor = require("@cypress/webpack-preprocessor");
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on(
"file:preprocessor",
preprocessor()
);
// implement node event listeners here
},
},
}); Now it's working. Please try that. Here's my repo: https://github.com/lmiller1990/cypress-preprocessor-example |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm trying to write unit tests for the handlers, getting the below error while running the test. Any support please?
Error: Webpack Compilation Error
./node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/signature-v4/dist-es/getCanonicalHeaders.js 10:30
Module parse failed: Unexpected token (10:30)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| const canonicalHeaderName = headerName.toLowerCase();
| if (canonicalHeaderName in ALWAYS_UNSIGNABLE_HEADERS ||
| PROXY_HEADER_PATTERN.test(canonicalHeaderName) ||
| SEC_HEADER_PATTERN.test(canonicalHeaderName)) {
@ ./node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/signature-v4/dist-es/index.js 2:0-60 2:0-60
@ ./node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/middleware-signing/dist-es/configurations.js
@ ./node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/middleware-signing/dist-es/index.js
@ ./node_modules/@aws-sdk/client-dynamodb/dist-es/DynamoDBClient.js
@ ./node_modules/@aws-sdk/client-dynamodb/dist-es/index.js
@ ./src/handlers/eoi/post_eoi.ts
@ ./src/index.ts
@ ./cypress/e2e/unit-tests/handlers/post_eoi.cy.ts
Test file: post_eoi.cy.ts
import { post_eoi } from '../../../../src'
describe('Unit: post_eoi', function () {
before(() => {
expect(post_eoi).to.be.a('function')
})
})
Beta Was this translation helpful? Give feedback.
All reactions