gpt4 book ai didi

amazon-web-services - TestCafe 与 SAM Local 一起工作,但在 SAM Deploy 之后不工作

转载 作者:行者123 更新时间:2023-11-28 20:34:39 28 4
gpt4 key购买 nike

我目前正在尝试设置一个应该执行简单 TestCafe 测试的 AWS Lambda (nodejs10.x) 函数。

如果我使用 sam local invoke --no-event 在本地运行我的 Lambda,它执行得很好:

2019-12-03T13:39:46.345Z 7b906b79-d7e5-1aa6-edb7-3e749d4e4b08
INFO hello world ✓ My first test 1 passed (1s) 2019-12-03T13:39:46.578Z 7b906b79-d7e5-1aa6-edb7-3e749d4e4b08
INFO Tests failed: 0

在我使用 sam buildsam deploy 部署它后,它停止工作。它只会在 AWS 中抛出以下错误:

{
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "Error: Page crashed!",
"trace": [
"Runtime.UnhandledPromiseRejection: Error: Page crashed!",
" at process.on (/var/runtime/index.js:37:15)",
" at process.emit (events.js:203:15)",
" at process.EventEmitter.emit (domain.js:448:20)",
" at emitPromiseRejectionWarnings (internal/process/promises.js:140:18)",
" at process._tickCallback (internal/process/next_tick.js:69:34)"
]
}

我的 lambda 处理程序如下所示:

const createTestCafe = require("testcafe");
const chromium = require("chrome-aws-lambda");
let testcafe = null;

exports.lambdaHandler = async (event, context) => {
const executablePath = await chromium.executablePath;

await createTestCafe()
.then(tc => {
testcafe = tc;
const runner = testcafe.createRunner();

return runner
.src("sample-fixture.js")
.browsers(
"puppeteer-core:launch?arg=--no-sandbox&arg=--disable-gpu&arg=--disable-setuid-sandbox&path=" + executablePath
)
.run({
skipJsErrors: true,
selectorTimeout: 50000
});
})
.then(failedCount => {
console.log("Tests failed: " + failedCount);
testcafe.close();
});

return {
statusCode: 200
};
};

我的 sample-fixture.js 看起来像这样:

fixture `Getting Started`
.page `http://devexpress.github.io/testcafe/example`;

test('My first test', async t => {
console.log('hello world');
});

我正在使用以下依赖项:

  • "testcafe": "^1.7.0"

  • "chrome-aws-lambda": "^2.0.1"

  • "testcafe-browser-provider-puppeteer-core": "^1.1.0"

有人知道为什么我的 Lambda 函数可以在我的机器上本地运行,但不能在 AWS 上运行吗?

最佳答案

我目前不能仅根据这些信息说出任何准确的信息。我建议您尝试以下操作:

关于amazon-web-services - TestCafe 与 SAM Local 一起工作,但在 SAM Deploy 之后不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59158717/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com