From 572097e0873d9494bd57967095c77980e2411dfc Mon Sep 17 00:00:00 2001 From: dnalborczyk Date: Tue, 3 Jan 2023 22:48:12 -0500 Subject: [PATCH] refactor: use desm (#1641) --- package-lock.json | 52 ++++++++++++------- package.json | 5 +- src/events/http/Endpoint.js | 9 ++-- src/lambda/__tests__/LambdaFunction.test.js | 7 +-- .../python-runner/PythonRunner.js | 10 ++-- .../handler-runner/ruby-runner/RubyRunner.js | 8 ++- .../WorkerThreadRunner.js | 29 +++++------ tests/_testHelpers/setupTeardown.js | 9 ++-- .../environmentVariables.test.js | 7 +-- .../optionParameters/optionParameters.test.js | 11 ++-- .../end-to-end/starRoutes/starRoutes.test.js | 7 +-- .../starRoutesRestApi.test.js | 7 +-- .../starRoutes.test.js | 7 +-- .../generated-api-key.test.js | 7 +-- .../provider-apiGateway-apiKeys.test.js | 7 +-- .../commonjs/handlerModuleFormats.test.js | 7 +-- .../module/handlerModuleFormats.test.js | 7 +-- .../alb-handler/handlerPayload.test.js | 9 ++-- .../artifact/local/localArtifact.test.js | 11 ++-- .../integration/authorizer/authorizer.test.js | 7 +-- .../authenticationCustomVariable.test.js | 7 +-- .../docker/access-host/accessHost.test.js | 9 ++-- .../docker/artifact/artifact.test.js | 11 ++-- .../docker/go/go1.x/dockerGo1.x.test.js | 18 +++---- .../docker/layers/dockerLayers.test.js | 7 +-- .../docker/multiple/dockerMultiple.test.js | 7 +-- .../nodejs12.x/dockerNodejs12.x.test.js | 7 +-- .../docker/provided/dockerProvided.test.js | 7 +-- .../python/python3.6/dockerPython3.6.test.js | 7 +-- .../python/python3.7/dockerPython3.7.test.js | 7 +-- .../python/python3.8/dockerPython3.8.test.js | 7 +-- .../docker/ruby/ruby2.7/dockerRuby2.7.test.js | 7 +-- .../handler/handlerPayload.test.js | 11 ++-- .../httpApi-cors-default.test.js | 7 +-- .../httpApi-cors/httpApi-cors.test.js | 7 +-- .../httpApi-headers/httpApi-headers.test.js | 7 +-- .../jwt-authorizer/jwt-authorizer.test.js | 7 +-- .../lambdaIntegration.test.js | 7 +-- .../lambdaInvoke.test.js | 9 ++-- .../lambdaInvokeAsync.test.js | 9 ++-- .../lambdaInvoke.test.js | 9 ++-- .../lambdaInvokeAsync.test.js | 9 ++-- .../override-authorizer.test.js | 7 +-- .../request-authorizer.test.js | 7 +-- .../uncategorized/uncategorized.test.js | 7 +-- .../websocket-authorizer.test.js | 7 +-- .../websocket-oneway/websocket-oneway.test.js | 7 +-- .../websocket-twoway/websocket-twoway.test.js | 7 +-- .../env-vars/in-process-env-vars.test.js | 7 +-- .../instances/in-process-instances.test.js | 7 +-- .../env-vars/worker-threads-env-vars.test.js | 7 +-- .../worker-threads-instances.test.js | 7 +-- .../worker-threads-local-env-vars.test.js | 7 +-- .../reload-handler/reload-handler.test.js | 7 +-- .../timeout/worker-threads-timeout.test.js | 7 +-- .../aws-golang-simple-http-endpoint.test.js | 7 +-- tests/runtimes/go/go1.x/go1.x.test.js | 7 +-- tests/runtimes/java/groovy/groovy.test.js | 7 +-- tests/runtimes/java/java/java.test.js | 7 +-- tests/runtimes/java/kotlin/kotlin.test.js | 7 +-- tests/runtimes/java/scala/scala.test.js | 7 +-- .../python-big-json/python-big-json.test.js | 7 +-- .../python-module/python-module.test.js | 7 +-- tests/runtimes/python/python3/python3.test.js | 7 +-- tests/runtimes/ruby/ruby.test.js | 7 +-- .../docker-in-docker/docker-in-docker.test.js | 17 +++--- .../docker-serverless-webpack.test.js | 9 ++-- .../apollo-federation-supergraph.test.js | 9 ++-- .../app/gateway/src/index.js | 10 ++-- .../app/inventory/src/index.js | 7 +-- .../app/products/src/index.js | 7 +-- .../app/users/src/index.js | 7 +-- .../apollo-server-integrations.test.js | 9 ++-- .../middy-lambda/middy-lambda.test.js | 9 ++-- .../serverless-http-with-express.test.js | 9 ++-- ...articuz-chrome-aws-lambda-http-api.test.js | 9 ++-- .../sparticuz-chrome-aws-lambda-http.test.js | 9 ++-- .../vendia-serverless-express.test.js | 12 ++--- .../serverless-esbuild.test.js | 9 ++-- .../serverless-plugin-typescript.test.js | 9 ++-- .../serverless-webpack.test.js | 9 ++-- tests/timeout/timeout.test.js | 7 +-- 82 files changed, 252 insertions(+), 472 deletions(-) diff --git a/package-lock.json b/package-lock.json index bae237168..84ffcfb99 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "array-unflat-js": "^0.1.3", "boxen": "^7.0.1", "chalk": "^5.2.0", + "desm": "^1.3.0", "execa": "^6.1.0", "fs-extra": "^11.1.0", "is-wsl": "^2.2.0", @@ -40,12 +41,12 @@ "archiver": "^5.3.1", "eslint": "^8.31.0", "eslint-config-airbnb-base": "^15.0.0", - "eslint-config-prettier": "^8.5.0", + "eslint-config-prettier": "^8.6.0", "eslint-plugin-import": "^2.25.4", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-unicorn": "^45.0.2", "git-list-updated": "^1.2.1", - "husky": "^8.0.2", + "husky": "^8.0.3", "lint-staged": "^13.1.0", "mocha": "^10.2.0", "nyc": "^15.1.0", @@ -2508,9 +2509,9 @@ } }, "node_modules/ajv-formats/node_modules/ajv": { - "version": "8.11.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.2.tgz", - "integrity": "sha512-E4bfmKAhGiSTvMfL1Myyycaub+cUEU2/IvpylXkUu7CHBkBj1f/ikdzbD7YQ6FKUbixDxeYvB/xY4fvyroDlQg==", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "dev": true, "dependencies": { "fast-deep-equal": "^3.1.1", @@ -2862,9 +2863,9 @@ } }, "node_modules/aws-sdk": { - "version": "2.1286.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1286.0.tgz", - "integrity": "sha512-CvkCD1+NSk2MPOutD2hEPhXDET/79w/gd9a359QWb9Ja0Fd4vVFXPkhlm1DTGzuwqFKGinpCMxDP4md7QPsVvw==", + "version": "2.1287.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1287.0.tgz", + "integrity": "sha512-mtfDstUdFNn8FnBaXs2KAaQ0cgDIiwlqwC2UptUKWWrugjZHAoRacfD/6bnah1Kwhu43F9CDEe5QLHnQtymNkw==", "dev": true, "dependencies": { "buffer": "4.9.2", @@ -3451,9 +3452,15 @@ } }, "node_modules/ci-info": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.7.0.tgz", - "integrity": "sha512-2CpRNYmImPx+RXKLq6jko/L07phmS9I02TyqkcNU20GCF/GgaWvc58hPtjxDX8lPpkdwc9sNh72V9k00S7ezog==", + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.7.1.tgz", + "integrity": "sha512-4jYS4MOAaCIStSRwiuxc4B8MYhIe676yO1sYGzARnjXkWpmzZMMYxY6zu8WYWDhSuth5zhrQ1rhNSibyyvv4/w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], "engines": { "node": ">=8" } @@ -4759,6 +4766,11 @@ "node": ">=0.4.0" } }, + "node_modules/desm": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/desm/-/desm-1.3.0.tgz", + "integrity": "sha512-RvlHN2gfYA0BpCfjpWzCdQeR6p5U+84f5DzcirLow86UA/OcpwuOqXRC4Oz0bG9rzcJPVtMT6ZgNtjp4qh+uqA==" + }, "node_modules/detect-indent": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz", @@ -5177,9 +5189,9 @@ } }, "node_modules/eslint-config-prettier": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz", - "integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==", + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.6.0.tgz", + "integrity": "sha512-bAF0eLpLVqP5oEVUFKpMA+NnRFICwn9X8B5jrR9FcqnYBuPbqWEjTEspPWMj5ye6czoSLDweCzSo3Ko7gGrZaA==", "dev": true, "bin": { "eslint-config-prettier": "bin/cli.js" @@ -6845,9 +6857,9 @@ } }, "node_modules/husky": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.2.tgz", - "integrity": "sha512-Tkv80jtvbnkK3mYWxPZePGFpQ/tT3HNSs/sasF9P2YfkMezDl3ON37YN6jUUI4eTg5LcyVynlb6r4eyvOmspvg==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", + "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", "dev": true, "bin": { "husky": "lib/bin.js" @@ -10822,9 +10834,9 @@ } }, "node_modules/serverless/node_modules/ajv": { - "version": "8.11.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.2.tgz", - "integrity": "sha512-E4bfmKAhGiSTvMfL1Myyycaub+cUEU2/IvpylXkUu7CHBkBj1f/ikdzbD7YQ6FKUbixDxeYvB/xY4fvyroDlQg==", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "dev": true, "dependencies": { "fast-deep-equal": "^3.1.1", diff --git a/package.json b/package.json index 901037fca..4359a4487 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,7 @@ "array-unflat-js": "^0.1.3", "boxen": "^7.0.1", "chalk": "^5.2.0", + "desm": "^1.3.0", "execa": "^6.1.0", "fs-extra": "^11.1.0", "is-wsl": "^2.2.0", @@ -109,12 +110,12 @@ "archiver": "^5.3.1", "eslint": "^8.31.0", "eslint-config-airbnb-base": "^15.0.0", - "eslint-config-prettier": "^8.5.0", + "eslint-config-prettier": "^8.6.0", "eslint-plugin-import": "^2.25.4", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-unicorn": "^45.0.2", "git-list-updated": "^1.2.1", - "husky": "^8.0.2", + "husky": "^8.0.3", "lint-staged": "^13.1.0", "mocha": "^10.2.0", "nyc": "^15.1.0", diff --git a/src/events/http/Endpoint.js b/src/events/http/Endpoint.js index be572286f..3b82bb576 100644 --- a/src/events/http/Endpoint.js +++ b/src/events/http/Endpoint.js @@ -1,20 +1,17 @@ import { existsSync, readFileSync } from 'node:fs' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' import { log } from '@serverless/utils/log.js' +import { join } from 'desm' import OfflineEndpoint from './OfflineEndpoint.js' const { entries } = Object -const __dirname = dirname(fileURLToPath(import.meta.url)) - // velocity template defaults const defaultRequestTemplate = readFileSync( - resolve(__dirname, 'templates/offline-default.req.vm'), + join(import.meta.url, 'templates/offline-default.req.vm'), 'utf8', ) const defaultResponseTemplate = readFileSync( - resolve(__dirname, 'templates/offline-default.res.vm'), + join(import.meta.url, 'templates/offline-default.res.vm'), 'utf8', ) diff --git a/src/lambda/__tests__/LambdaFunction.test.js b/src/lambda/__tests__/LambdaFunction.test.js index e59570272..a3d45a793 100644 --- a/src/lambda/__tests__/LambdaFunction.test.js +++ b/src/lambda/__tests__/LambdaFunction.test.js @@ -1,19 +1,16 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' // import { performance } from 'node:perf_hooks' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import LambdaFunction from '../LambdaFunction.js' import { DEFAULT_LAMBDA_TIMEOUT } from '../../config/index.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('LambdaFunction', () => { const functionName = 'foo' const serverless = { config: { serverlessPath: '', - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }, service: { provider: { diff --git a/src/lambda/handler-runner/python-runner/PythonRunner.js b/src/lambda/handler-runner/python-runner/PythonRunner.js index 3cfae5566..c0cf288b4 100644 --- a/src/lambda/handler-runner/python-runner/PythonRunner.js +++ b/src/lambda/handler-runner/python-runner/PythonRunner.js @@ -1,17 +1,15 @@ import { spawn } from 'node:child_process' import { EOL, platform } from 'node:os' -import { delimiter, dirname, join, relative, resolve } from 'node:path' +import { delimiter, join as pathJoin, relative } from 'node:path' import process, { cwd, nextTick } from 'node:process' import { createInterface } from 'node:readline' -import { fileURLToPath } from 'node:url' import { log } from '@serverless/utils/log.js' +import { join } from 'desm' import { splitHandlerPathAndName } from '../../../utils/index.js' const { parse, stringify } = JSON const { assign, hasOwn } = Object -const __dirname = dirname(fileURLToPath(import.meta.url)) - export default class PythonRunner { static #payloadIdentifier = '__offline_payload__' @@ -32,7 +30,7 @@ export default class PythonRunner { const runtimeDir = platform() === 'win32' ? 'Scripts' : 'bin' process.env.PATH = [ - join(process.env.VIRTUAL_ENV, runtimeDir), + pathJoin(process.env.VIRTUAL_ENV, runtimeDir), delimiter, process.env.PATH, ].join('') @@ -44,7 +42,7 @@ export default class PythonRunner { pythonExecutable, [ '-u', - resolve(__dirname, 'invoke.py'), + join(import.meta.url, 'invoke.py'), relative(cwd(), handlerPath), handlerName, ], diff --git a/src/lambda/handler-runner/ruby-runner/RubyRunner.js b/src/lambda/handler-runner/ruby-runner/RubyRunner.js index 3d2902c9b..0db1298de 100644 --- a/src/lambda/handler-runner/ruby-runner/RubyRunner.js +++ b/src/lambda/handler-runner/ruby-runner/RubyRunner.js @@ -1,16 +1,14 @@ import { EOL, platform } from 'node:os' -import { dirname, relative, resolve } from 'node:path' +import { relative } from 'node:path' import { cwd } from 'node:process' -import { fileURLToPath } from 'node:url' import { log } from '@serverless/utils/log.js' +import { join } from 'desm' import { execa } from 'execa' import { splitHandlerPathAndName } from '../../../utils/index.js' const { parse, stringify } = JSON const { hasOwn } = Object -const __dirname = dirname(fileURLToPath(import.meta.url)) - export default class RubyRunner { static #payloadIdentifier = '__offline_payload__' @@ -86,7 +84,7 @@ export default class RubyRunner { const { stderr, stdout } = await execa( runtime, [ - resolve(__dirname, 'invoke.rb'), + join(import.meta.url, 'invoke.rb'), relative(cwd(), this.#handlerPath), this.#handlerName, ], diff --git a/src/lambda/handler-runner/worker-thread-runner/WorkerThreadRunner.js b/src/lambda/handler-runner/worker-thread-runner/WorkerThreadRunner.js index 4d3910cea..9e3aed51d 100644 --- a/src/lambda/handler-runner/worker-thread-runner/WorkerThreadRunner.js +++ b/src/lambda/handler-runner/worker-thread-runner/WorkerThreadRunner.js @@ -1,9 +1,5 @@ -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' import { MessageChannel, Worker } from 'node:worker_threads' - -const __dirname = dirname(fileURLToPath(import.meta.url)) -const workerThreadHelperPath = resolve(__dirname, 'workerThreadHelper.js') +import { join } from 'desm' export default class WorkerThreadRunner { #workerThread = null @@ -11,17 +7,20 @@ export default class WorkerThreadRunner { constructor(funOptions, env) { const { codeDir, functionKey, handler, servicePath, timeout } = funOptions - this.#workerThread = new Worker(workerThreadHelperPath, { - // don't pass process.env from the main process! - env, - workerData: { - codeDir, - functionKey, - handler, - servicePath, - timeout, + this.#workerThread = new Worker( + join(import.meta.url, 'workerThreadHelper.js'), + { + // don't pass process.env from the main process! + env, + workerData: { + codeDir, + functionKey, + handler, + servicePath, + timeout, + }, }, - }) + ) } // () => Promise diff --git a/tests/_testHelpers/setupTeardown.js b/tests/_testHelpers/setupTeardown.js index 63357b939..1844dd90a 100644 --- a/tests/_testHelpers/setupTeardown.js +++ b/tests/_testHelpers/setupTeardown.js @@ -1,14 +1,11 @@ -import { dirname, resolve } from 'node:path' import process, { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { execaNode } from 'execa' let serverlessProcess -const __dirname = dirname(fileURLToPath(import.meta.url)) - -const serverlessPath = resolve( - __dirname, +const serverlessPath = join( + import.meta.url, '../../node_modules/serverless/bin/serverless', ) diff --git a/tests/end-to-end/environmentVariables/environmentVariables.test.js b/tests/end-to-end/environmentVariables/environmentVariables.test.js index 43112bb40..ab8aa8553 100644 --- a/tests/end-to-end/environmentVariables/environmentVariables.test.js +++ b/tests/end-to-end/environmentVariables/environmentVariables.test.js @@ -1,12 +1,9 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { BASE_URL } from '../../config.js' import { setup, teardown } from '../../_testHelpers/index.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('environment variables', function desc() { const ENV_VAR_QUOTED = 'I am ENV_VAR_1' const ENV_VAR_UNQUOTED = 'I am ENV_VAR_2' @@ -20,7 +17,7 @@ describe('environment variables', function desc() { env.ENV_VAR_MAPPED_FROM_ANOTHER = ENV_VAR_MAPPED await setup({ - servicePath: resolve(__dirname, 'src'), + servicePath: join(import.meta.url, 'src'), }) const url = new URL('/dev/hello', BASE_URL) diff --git a/tests/end-to-end/optionParameters/optionParameters.test.js b/tests/end-to-end/optionParameters/optionParameters.test.js index d9f99a4c8..a64f8b4d1 100644 --- a/tests/end-to-end/optionParameters/optionParameters.test.js +++ b/tests/end-to-end/optionParameters/optionParameters.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { BASE_URL } from '../../config.js' import { setup, teardown } from '../../_testHelpers/index.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('noPrependStageInUrl option', function desc() { beforeEach(() => setup({ args: ['--noPrependStageInUrl'], - servicePath: resolve(__dirname, 'src'), + servicePath: join(import.meta.url, 'src'), }), ) @@ -61,7 +58,7 @@ describe('prefix option', function desc() { beforeEach(() => setup({ args: ['--prefix', 'someprefix'], - servicePath: resolve(__dirname, 'src'), + servicePath: join(import.meta.url, 'src'), }), ) @@ -114,7 +111,7 @@ describe('noPrependStageInUrl option with prefix option', function desc() { beforeEach(() => setup({ args: ['--noPrependStageInUrl', '--prefix', 'someprefix'], - servicePath: resolve(__dirname, 'src'), + servicePath: join(import.meta.url, 'src'), }), ) diff --git a/tests/end-to-end/starRoutes/starRoutes.test.js b/tests/end-to-end/starRoutes/starRoutes.test.js index 6c9112b10..7e9b1cae2 100644 --- a/tests/end-to-end/starRoutes/starRoutes.test.js +++ b/tests/end-to-end/starRoutes/starRoutes.test.js @@ -1,15 +1,12 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { BASE_URL } from '../../config.js' import { setup, teardown } from '../../_testHelpers/index.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('star routes', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname, 'src'), + servicePath: join(import.meta.url, 'src'), }), ) diff --git a/tests/end-to-end/starRoutesRestApi/starRoutesRestApi.test.js b/tests/end-to-end/starRoutesRestApi/starRoutesRestApi.test.js index f05ababd4..beee3e7c3 100644 --- a/tests/end-to-end/starRoutesRestApi/starRoutesRestApi.test.js +++ b/tests/end-to-end/starRoutesRestApi/starRoutesRestApi.test.js @@ -1,15 +1,12 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { BASE_URL } from '../../config.js' import { setup, teardown } from '../../_testHelpers/index.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('star routes', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname, 'src'), + servicePath: join(import.meta.url, 'src'), }), ) diff --git a/tests/end-to-end/starRoutesWithProperties/starRoutes.test.js b/tests/end-to-end/starRoutesWithProperties/starRoutes.test.js index e158b7501..25a6e3aaf 100644 --- a/tests/end-to-end/starRoutesWithProperties/starRoutes.test.js +++ b/tests/end-to-end/starRoutesWithProperties/starRoutes.test.js @@ -1,15 +1,12 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { BASE_URL } from '../../config.js' import { setup, teardown } from '../../_testHelpers/index.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('star routes with properties', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname, 'src'), + servicePath: join(import.meta.url, 'src'), }), ) diff --git a/tests/events/http/private/generated-api-key/generated-api-key.test.js b/tests/events/http/private/generated-api-key/generated-api-key.test.js index 3816b3e26..77a6d5e3d 100644 --- a/tests/events/http/private/generated-api-key/generated-api-key.test.js +++ b/tests/events/http/private/generated-api-key/generated-api-key.test.js @@ -1,11 +1,8 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../../_testHelpers/index.js' import { BASE_URL } from '../../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('generated api key tests', function desc() { it('...', async () => { let stdoutData @@ -24,7 +21,7 @@ describe('generated api key tests', function desc() { }) await setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), stdoutData, }) diff --git a/tests/events/http/private/provider-apiGateway-apiKeys/provider-apiGateway-apiKeys.test.js b/tests/events/http/private/provider-apiGateway-apiKeys/provider-apiGateway-apiKeys.test.js index bd9401131..57ed7fcc1 100644 --- a/tests/events/http/private/provider-apiGateway-apiKeys/provider-apiGateway-apiKeys.test.js +++ b/tests/events/http/private/provider-apiGateway-apiKeys/provider-apiGateway-apiKeys.test.js @@ -1,15 +1,12 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../../_testHelpers/index.js' import { BASE_URL } from '../../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('provider.apiGateway.apiKeys tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/handler-module-formats/commonjs/handlerModuleFormats.test.js b/tests/handler-module-formats/commonjs/handlerModuleFormats.test.js index 41935095d..4d456f91e 100644 --- a/tests/handler-module-formats/commonjs/handlerModuleFormats.test.js +++ b/tests/handler-module-formats/commonjs/handlerModuleFormats.test.js @@ -1,15 +1,12 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('handler module format: commonjs', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/handler-module-formats/module/handlerModuleFormats.test.js b/tests/handler-module-formats/module/handlerModuleFormats.test.js index 7ef0f31c3..fde76ee53 100644 --- a/tests/handler-module-formats/module/handlerModuleFormats.test.js +++ b/tests/handler-module-formats/module/handlerModuleFormats.test.js @@ -1,15 +1,12 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('handler module format: module', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/alb-handler/handlerPayload.test.js b/tests/integration/alb-handler/handlerPayload.test.js index 168ef110e..694a6de06 100644 --- a/tests/integration/alb-handler/handlerPayload.test.js +++ b/tests/integration/alb-handler/handlerPayload.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('ALB handler payload tests', function desc() { beforeEach(() => setup({ noPrependStageInUrl: false, - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) @@ -178,7 +175,7 @@ describe('ALB handler payload tests with prepend off', function desc() { beforeEach(() => setup({ args: ['--noPrependStageInUrl'], - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/artifact/local/localArtifact.test.js b/tests/integration/artifact/local/localArtifact.test.js index fe0e42e3b..641fd1c64 100644 --- a/tests/integration/artifact/local/localArtifact.test.js +++ b/tests/integration/artifact/local/localArtifact.test.js @@ -1,6 +1,5 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { BASE_URL } from '../../../config.js' import { compressArtifact, @@ -8,23 +7,21 @@ import { teardown, } from '../../../_testHelpers/index.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Local artifact tests', function desc() { beforeEach(async () => { await Promise.all([ - compressArtifact(__dirname, 'artifacts/hello1.zip', [ + compressArtifact(join(import.meta.url), 'artifacts/hello1.zip', [ 'src/handler1.js', 'src/package.json', ]), - compressArtifact(__dirname, 'artifacts/hello2.zip', [ + compressArtifact(join(import.meta.url), 'artifacts/hello2.zip', [ 'src/handler2.js', 'src/package.json', ]), ]) await setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }) }) diff --git a/tests/integration/authorizer/authorizer.test.js b/tests/integration/authorizer/authorizer.test.js index 077ae4308..c72928bb2 100644 --- a/tests/integration/authorizer/authorizer.test.js +++ b/tests/integration/authorizer/authorizer.test.js @@ -2,17 +2,14 @@ // https://dev.to/piczmar_0/serverless-authorizers---custom-rest-authorizer-16 import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { BASE_URL } from '../../config.js' import { setup, teardown } from '../../_testHelpers/index.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('lalala authorizer tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/custom-authentication/authenticationCustomVariable.test.js b/tests/integration/custom-authentication/authenticationCustomVariable.test.js index 4e05f12cc..6a3372030 100644 --- a/tests/integration/custom-authentication/authenticationCustomVariable.test.js +++ b/tests/integration/custom-authentication/authenticationCustomVariable.test.js @@ -1,15 +1,12 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { BASE_URL } from '../../config.js' import { setup, teardown } from '../../_testHelpers/index.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('custom authentication serverless-offline variable tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/docker/access-host/accessHost.test.js b/tests/integration/docker/access-host/accessHost.test.js index 79478af7b..f176ab2e2 100644 --- a/tests/integration/docker/access-host/accessHost.test.js +++ b/tests/integration/docker/access-host/accessHost.test.js @@ -1,19 +1,16 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' import { Server } from '@hapi/hapi' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import installNpmModules from '../../../installNpmModules.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Access host with Docker tests', function desc() { let server beforeEach(async () => { - await installNpmModules(resolve(__dirname, 'src')) + await installNpmModules(join(import.meta.url, 'src')) }) beforeEach(async () => { @@ -29,7 +26,7 @@ describe('Access host with Docker tests', function desc() { await server.start() await setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }) }) diff --git a/tests/integration/docker/artifact/artifact.test.js b/tests/integration/docker/artifact/artifact.test.js index e61a747d7..406c0be42 100644 --- a/tests/integration/docker/artifact/artifact.test.js +++ b/tests/integration/docker/artifact/artifact.test.js @@ -1,7 +1,6 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { compressArtifact, setup, @@ -9,13 +8,13 @@ import { } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Artifact with docker tests', function desc() { beforeEach(async () => { - await compressArtifact(__dirname, 'artifacts/hello.zip', ['handler.js']) + await compressArtifact(join(import.meta.url), 'artifacts/hello.zip', [ + 'handler.js', + ]) return setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }) }) diff --git a/tests/integration/docker/go/go1.x/dockerGo1.x.test.js b/tests/integration/docker/go/go1.x/dockerGo1.x.test.js index f174a8cc7..7ed1dd945 100644 --- a/tests/integration/docker/go/go1.x/dockerGo1.x.test.js +++ b/tests/integration/docker/go/go1.x/dockerGo1.x.test.js @@ -1,8 +1,7 @@ import assert from 'node:assert' import { platform } from 'node:os' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { buildInContainer, setup, @@ -10,12 +9,10 @@ import { } from '../../../../_testHelpers/index.js' import { BASE_URL } from '../../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Go 1.x with Docker tests', function desc() { beforeEach(async () => { await setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }) }) @@ -38,11 +35,12 @@ describe('Go 1.x with Docker tests', function desc() { this.skip() } - await buildInContainer('go1.x', resolve(__dirname), '/go/src/handler', [ - 'make', - 'clean', - 'build', - ]) + await buildInContainer( + 'go1.x', + join(import.meta.url), + '/go/src/handler', + ['make', 'clean', 'build'], + ) const url = new URL(path, BASE_URL) const response = await fetch(url) diff --git a/tests/integration/docker/layers/dockerLayers.test.js b/tests/integration/docker/layers/dockerLayers.test.js index 309af28fc..89805cdfd 100644 --- a/tests/integration/docker/layers/dockerLayers.test.js +++ b/tests/integration/docker/layers/dockerLayers.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Layers with Docker tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/docker/multiple/dockerMultiple.test.js b/tests/integration/docker/multiple/dockerMultiple.test.js index 46fe5030b..82cecdda9 100644 --- a/tests/integration/docker/multiple/dockerMultiple.test.js +++ b/tests/integration/docker/multiple/dockerMultiple.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Multiple docker containers', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/docker/nodejs/nodejs12.x/dockerNodejs12.x.test.js b/tests/integration/docker/nodejs/nodejs12.x/dockerNodejs12.x.test.js index 7d6c3f67b..3a33e13fd 100644 --- a/tests/integration/docker/nodejs/nodejs12.x/dockerNodejs12.x.test.js +++ b/tests/integration/docker/nodejs/nodejs12.x/dockerNodejs12.x.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../../_testHelpers/index.js' import { BASE_URL } from '../../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Node.js 12.x with Docker tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/docker/provided/dockerProvided.test.js b/tests/integration/docker/provided/dockerProvided.test.js index ba2b28dc8..12a1520f1 100644 --- a/tests/integration/docker/provided/dockerProvided.test.js +++ b/tests/integration/docker/provided/dockerProvided.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Provided with Docker tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/docker/python/python3.6/dockerPython3.6.test.js b/tests/integration/docker/python/python3.6/dockerPython3.6.test.js index 1bd1ffbb0..3e8d6fcf2 100644 --- a/tests/integration/docker/python/python3.6/dockerPython3.6.test.js +++ b/tests/integration/docker/python/python3.6/dockerPython3.6.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../../_testHelpers/index.js' import { BASE_URL } from '../../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Python 3.6 with Docker tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/docker/python/python3.7/dockerPython3.7.test.js b/tests/integration/docker/python/python3.7/dockerPython3.7.test.js index 6d58b673e..6b6df2869 100644 --- a/tests/integration/docker/python/python3.7/dockerPython3.7.test.js +++ b/tests/integration/docker/python/python3.7/dockerPython3.7.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../../_testHelpers/index.js' import { BASE_URL } from '../../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Python 3.7 with Docker tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/docker/python/python3.8/dockerPython3.8.test.js b/tests/integration/docker/python/python3.8/dockerPython3.8.test.js index fba35105b..533ce0cbe 100644 --- a/tests/integration/docker/python/python3.8/dockerPython3.8.test.js +++ b/tests/integration/docker/python/python3.8/dockerPython3.8.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../../_testHelpers/index.js' import { BASE_URL } from '../../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Python 3.8 with Docker tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/docker/ruby/ruby2.7/dockerRuby2.7.test.js b/tests/integration/docker/ruby/ruby2.7/dockerRuby2.7.test.js index d5a15f393..469358b8f 100644 --- a/tests/integration/docker/ruby/ruby2.7/dockerRuby2.7.test.js +++ b/tests/integration/docker/ruby/ruby2.7/dockerRuby2.7.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../../_testHelpers/index.js' import { BASE_URL } from '../../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Ruby 2.7 with Docker tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/handler/handlerPayload.test.js b/tests/integration/handler/handlerPayload.test.js index 47ac84829..d7bbbffd7 100644 --- a/tests/integration/handler/handlerPayload.test.js +++ b/tests/integration/handler/handlerPayload.test.js @@ -1,18 +1,15 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' const { stringify } = JSON -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('handler payload tests', function desc() { beforeEach(() => setup({ noPrependStageInUrl: false, - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) @@ -180,7 +177,7 @@ describe('handler payload tests with prepend off', function desc() { beforeEach(() => setup({ args: ['--noPrependStageInUrl'], - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) @@ -327,7 +324,7 @@ describe('handler payload schemas validation tests', function desc() { beforeEach(() => setup({ args: ['--noPrependStageInUrl'], - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/httpApi-cors-default/httpApi-cors-default.test.js b/tests/integration/httpApi-cors-default/httpApi-cors-default.test.js index e9f1cee96..6fd8d9a49 100644 --- a/tests/integration/httpApi-cors-default/httpApi-cors-default.test.js +++ b/tests/integration/httpApi-cors-default/httpApi-cors-default.test.js @@ -2,17 +2,14 @@ // https://dev.to/piczmar_0/serverless-authorizers---custom-rest-authorizer-16 import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('HttpApi Cors Default Tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/httpApi-cors/httpApi-cors.test.js b/tests/integration/httpApi-cors/httpApi-cors.test.js index c12d21518..e731ec770 100644 --- a/tests/integration/httpApi-cors/httpApi-cors.test.js +++ b/tests/integration/httpApi-cors/httpApi-cors.test.js @@ -2,17 +2,14 @@ // https://dev.to/piczmar_0/serverless-authorizers---custom-rest-authorizer-16 import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('HttpApi Cors Tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/httpApi-headers/httpApi-headers.test.js b/tests/integration/httpApi-headers/httpApi-headers.test.js index bcea809ee..e58916640 100644 --- a/tests/integration/httpApi-headers/httpApi-headers.test.js +++ b/tests/integration/httpApi-headers/httpApi-headers.test.js @@ -1,15 +1,12 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('HttpApi Headers Tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/jwt-authorizer/jwt-authorizer.test.js b/tests/integration/jwt-authorizer/jwt-authorizer.test.js index 261264366..6773c182f 100644 --- a/tests/integration/jwt-authorizer/jwt-authorizer.test.js +++ b/tests/integration/jwt-authorizer/jwt-authorizer.test.js @@ -3,8 +3,7 @@ import assert from 'node:assert' import { randomBytes } from 'node:crypto' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { SignJWT } from 'jose' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' @@ -12,8 +11,6 @@ import { BASE_URL } from '../../config.js' const { now } = Date const { floor } = Math -const __dirname = dirname(fileURLToPath(import.meta.url)) - const secret = randomBytes(256) const baseJWT = { @@ -78,7 +75,7 @@ describe('jwt authorizer tests', function desc() { beforeEach(() => setup({ args: ['--ignoreJWTSignature'], - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/lambda-integration/lambdaIntegration.test.js b/tests/integration/lambda-integration/lambdaIntegration.test.js index 4773bf7cb..bedc54ca4 100644 --- a/tests/integration/lambda-integration/lambdaIntegration.test.js +++ b/tests/integration/lambda-integration/lambdaIntegration.test.js @@ -1,17 +1,14 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' const { stringify } = JSON -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('lambda integration tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/lambda-invoke-aws-sdk-v2/lambdaInvoke.test.js b/tests/integration/lambda-invoke-aws-sdk-v2/lambdaInvoke.test.js index e6e11a43d..d00790a56 100644 --- a/tests/integration/lambda-invoke-aws-sdk-v2/lambdaInvoke.test.js +++ b/tests/integration/lambda-invoke-aws-sdk-v2/lambdaInvoke.test.js @@ -1,6 +1,5 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' import installNpmModules from '../../installNpmModules.js' @@ -8,16 +7,14 @@ import installNpmModules from '../../installNpmModules.js' const { isArray } = Array const { parse, stringify } = JSON -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Lambda.invoke aws-sdk v2 tests', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'src')) + await installNpmModules(join(import.meta.url, 'src')) }) beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/lambda-invoke-aws-sdk-v2/lambdaInvokeAsync.test.js b/tests/integration/lambda-invoke-aws-sdk-v2/lambdaInvokeAsync.test.js index 592c44193..b5210dc57 100644 --- a/tests/integration/lambda-invoke-aws-sdk-v2/lambdaInvokeAsync.test.js +++ b/tests/integration/lambda-invoke-aws-sdk-v2/lambdaInvokeAsync.test.js @@ -1,20 +1,17 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' import installNpmModules from '../../installNpmModules.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Lambda.invokeAsync aws-sdk v2 tests', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'src')) + await installNpmModules(join(import.meta.url, 'src')) }) beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/lambda-invoke-aws-sdk-v3/lambdaInvoke.test.js b/tests/integration/lambda-invoke-aws-sdk-v3/lambdaInvoke.test.js index 610d73fcc..ccba1f87c 100644 --- a/tests/integration/lambda-invoke-aws-sdk-v3/lambdaInvoke.test.js +++ b/tests/integration/lambda-invoke-aws-sdk-v3/lambdaInvoke.test.js @@ -1,6 +1,5 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' import installNpmModules from '../../installNpmModules.js' @@ -8,16 +7,14 @@ import installNpmModules from '../../installNpmModules.js' const { isArray } = Array const { parse, stringify } = JSON -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Lambda.invoke aws-sdk v3 tests', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'src')) + await installNpmModules(join(import.meta.url, 'src')) }) beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/lambda-invoke-aws-sdk-v3/lambdaInvokeAsync.test.js b/tests/integration/lambda-invoke-aws-sdk-v3/lambdaInvokeAsync.test.js index c4e5e258a..7a3dacca1 100644 --- a/tests/integration/lambda-invoke-aws-sdk-v3/lambdaInvokeAsync.test.js +++ b/tests/integration/lambda-invoke-aws-sdk-v3/lambdaInvokeAsync.test.js @@ -1,20 +1,17 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' import installNpmModules from '../../installNpmModules.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Lambda.invokeAsync aws-sdk v3 tests', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'src')) + await installNpmModules(join(import.meta.url, 'src')) }) beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/override-authorizer/override-authorizer.test.js b/tests/integration/override-authorizer/override-authorizer.test.js index e58845ba1..bf57b0e44 100644 --- a/tests/integration/override-authorizer/override-authorizer.test.js +++ b/tests/integration/override-authorizer/override-authorizer.test.js @@ -1,14 +1,11 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' const { stringify } = JSON -const __dirname = dirname(fileURLToPath(import.meta.url)) - const envAuthorizer = { iam: { cognitoUser: { @@ -32,7 +29,7 @@ describe('override authorizer tests', function desc() { env.AUTHORIZER = stringify(envAuthorizer) await setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }) }) diff --git a/tests/integration/request-authorizer/request-authorizer.test.js b/tests/integration/request-authorizer/request-authorizer.test.js index 7359aa0c0..e45749a02 100644 --- a/tests/integration/request-authorizer/request-authorizer.test.js +++ b/tests/integration/request-authorizer/request-authorizer.test.js @@ -2,17 +2,14 @@ // https://dev.to/piczmar_0/serverless-authorizers---custom-rest-authorizer-16 import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { BASE_URL } from '../../config.js' import { setup, teardown } from '../../_testHelpers/index.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('request authorizer tests', () => { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/uncategorized/uncategorized.test.js b/tests/integration/uncategorized/uncategorized.test.js index d1db37d8b..03e394d1a 100644 --- a/tests/integration/uncategorized/uncategorized.test.js +++ b/tests/integration/uncategorized/uncategorized.test.js @@ -1,15 +1,12 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('uncategorized tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/websocket-authorizer/websocket-authorizer.test.js b/tests/integration/websocket-authorizer/websocket-authorizer.test.js index 181cf500e..c186cda36 100644 --- a/tests/integration/websocket-authorizer/websocket-authorizer.test.js +++ b/tests/integration/websocket-authorizer/websocket-authorizer.test.js @@ -1,17 +1,14 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { WebSocket } from 'ws' import { setup, teardown } from '../../_testHelpers/index.js' import websocketSend from '../../_testHelpers/websocketPromise.js' import { BASE_URL } from '../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('websocket authorizer tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/websocket-oneway/websocket-oneway.test.js b/tests/integration/websocket-oneway/websocket-oneway.test.js index 4624564be..87c7bb04d 100644 --- a/tests/integration/websocket-oneway/websocket-oneway.test.js +++ b/tests/integration/websocket-oneway/websocket-oneway.test.js @@ -1,6 +1,5 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { WebSocket } from 'ws' import { setup, teardown } from '../../_testHelpers/index.js' import websocketSend from '../../_testHelpers/websocketPromise.js' @@ -8,12 +7,10 @@ import { BASE_URL } from '../../config.js' const { parse, stringify } = JSON -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('one way websocket tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/integration/websocket-twoway/websocket-twoway.test.js b/tests/integration/websocket-twoway/websocket-twoway.test.js index 2e7238bfe..e8f477de7 100644 --- a/tests/integration/websocket-twoway/websocket-twoway.test.js +++ b/tests/integration/websocket-twoway/websocket-twoway.test.js @@ -1,6 +1,5 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { WebSocket } from 'ws' import { setup, teardown } from '../../_testHelpers/index.js' import websocketSend from '../../_testHelpers/websocketPromise.js' @@ -8,12 +7,10 @@ import { BASE_URL } from '../../config.js' const { parse, stringify } = JSON -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('two way websocket tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/lambda-run-mode/in-process/env-vars/in-process-env-vars.test.js b/tests/lambda-run-mode/in-process/env-vars/in-process-env-vars.test.js index b40794910..dea108b7c 100644 --- a/tests/lambda-run-mode/in-process/env-vars/in-process-env-vars.test.js +++ b/tests/lambda-run-mode/in-process/env-vars/in-process-env-vars.test.js @@ -1,18 +1,15 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('run mode with worker threads', function desc() { beforeEach(() => setup({ env: { SHOULD_BE_SHARED: 'SHOULD_BE_SHARED', }, - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/lambda-run-mode/in-process/instances/in-process-instances.test.js b/tests/lambda-run-mode/in-process/instances/in-process-instances.test.js index 265422ff0..452e5d935 100644 --- a/tests/lambda-run-mode/in-process/instances/in-process-instances.test.js +++ b/tests/lambda-run-mode/in-process/instances/in-process-instances.test.js @@ -1,18 +1,15 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' import { promisify } from 'node:util' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' const setTimeoutPromise = promisify(setTimeout) -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('run mode with in-process', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/lambda-run-mode/worker-threads/env-vars/worker-threads-env-vars.test.js b/tests/lambda-run-mode/worker-threads/env-vars/worker-threads-env-vars.test.js index 60cb6d69a..b101afc9c 100644 --- a/tests/lambda-run-mode/worker-threads/env-vars/worker-threads-env-vars.test.js +++ b/tests/lambda-run-mode/worker-threads/env-vars/worker-threads-env-vars.test.js @@ -1,11 +1,8 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('run mode with worker threads', function desc() { beforeEach(() => setup({ @@ -14,7 +11,7 @@ describe('run mode with worker threads', function desc() { AWS_FOOBAR: 'SHOULD_BE_SHARED', ENV_SHOULD_NOT_BE_SHARED: 'ENV_SHOULD_NOT_BE_SHARED', }, - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/lambda-run-mode/worker-threads/instances/worker-threads-instances.test.js b/tests/lambda-run-mode/worker-threads/instances/worker-threads-instances.test.js index 570235397..436a1904c 100644 --- a/tests/lambda-run-mode/worker-threads/instances/worker-threads-instances.test.js +++ b/tests/lambda-run-mode/worker-threads/instances/worker-threads-instances.test.js @@ -1,15 +1,12 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('run mode with worker threads', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/lambda-run-mode/worker-threads/local-env-vars/worker-threads-local-env-vars.test.js b/tests/lambda-run-mode/worker-threads/local-env-vars/worker-threads-local-env-vars.test.js index fceb8eb04..19f50a99e 100644 --- a/tests/lambda-run-mode/worker-threads/local-env-vars/worker-threads-local-env-vars.test.js +++ b/tests/lambda-run-mode/worker-threads/local-env-vars/worker-threads-local-env-vars.test.js @@ -1,11 +1,8 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('run mode with worker threads and --localEnvironment flag', function desc() { beforeEach(() => setup({ @@ -14,7 +11,7 @@ describe('run mode with worker threads and --localEnvironment flag', function de AWS_FOOBAR: 'SHOULD_BE_SHARED', ENV_SHOULD_BE_SHARED: 'ENV_SHOULD_BE_SHARED', }, - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/lambda-run-mode/worker-threads/reload-handler/reload-handler.test.js b/tests/lambda-run-mode/worker-threads/reload-handler/reload-handler.test.js index be1f0fefa..1efa49f38 100644 --- a/tests/lambda-run-mode/worker-threads/reload-handler/reload-handler.test.js +++ b/tests/lambda-run-mode/worker-threads/reload-handler/reload-handler.test.js @@ -1,15 +1,12 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('run mode with worker threads', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/lambda-run-mode/worker-threads/timeout/worker-threads-timeout.test.js b/tests/lambda-run-mode/worker-threads/timeout/worker-threads-timeout.test.js index 8252733f9..cd4e56884 100644 --- a/tests/lambda-run-mode/worker-threads/timeout/worker-threads-timeout.test.js +++ b/tests/lambda-run-mode/worker-threads/timeout/worker-threads-timeout.test.js @@ -1,15 +1,12 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('run mode with worker threads', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/runtimes/go/aws-golang-simple-http-endpoint/aws-golang-simple-http-endpoint.test.js b/tests/runtimes/go/aws-golang-simple-http-endpoint/aws-golang-simple-http-endpoint.test.js index fcff85f4c..80949c0c4 100644 --- a/tests/runtimes/go/aws-golang-simple-http-endpoint/aws-golang-simple-http-endpoint.test.js +++ b/tests/runtimes/go/aws-golang-simple-http-endpoint/aws-golang-simple-http-endpoint.test.js @@ -1,17 +1,14 @@ /* eslint-disable no-await-in-loop */ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('aws golang simple http endpoint', function desc() { beforeEach(async () => { await setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }) }) diff --git a/tests/runtimes/go/go1.x/go1.x.test.js b/tests/runtimes/go/go1.x/go1.x.test.js index 8b6160674..ced2c3f6d 100644 --- a/tests/runtimes/go/go1.x/go1.x.test.js +++ b/tests/runtimes/go/go1.x/go1.x.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Go 1.x with GoRunner', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/runtimes/java/groovy/groovy.test.js b/tests/runtimes/java/groovy/groovy.test.js index 040f82c43..4bc132a9e 100644 --- a/tests/runtimes/java/groovy/groovy.test.js +++ b/tests/runtimes/java/groovy/groovy.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Groovy tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/runtimes/java/java/java.test.js b/tests/runtimes/java/java/java.test.js index 86c15d2c7..bf6a13805 100644 --- a/tests/runtimes/java/java/java.test.js +++ b/tests/runtimes/java/java/java.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Java tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/runtimes/java/kotlin/kotlin.test.js b/tests/runtimes/java/kotlin/kotlin.test.js index 47665d74b..aedcc9bd0 100644 --- a/tests/runtimes/java/kotlin/kotlin.test.js +++ b/tests/runtimes/java/kotlin/kotlin.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Kotlin tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/runtimes/java/scala/scala.test.js b/tests/runtimes/java/scala/scala.test.js index 2c0a42b95..452513116 100644 --- a/tests/runtimes/java/scala/scala.test.js +++ b/tests/runtimes/java/scala/scala.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Scala tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/runtimes/python/python-big-json/python-big-json.test.js b/tests/runtimes/python/python-big-json/python-big-json.test.js index 914fcc9c2..d246c87d9 100644 --- a/tests/runtimes/python/python-big-json/python-big-json.test.js +++ b/tests/runtimes/python/python-big-json/python-big-json.test.js @@ -1,17 +1,14 @@ import assert from 'node:assert' import { platform } from 'node:os' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Python 3 tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/runtimes/python/python-module/python-module.test.js b/tests/runtimes/python/python-module/python-module.test.js index fcc124da4..a2dbf668e 100644 --- a/tests/runtimes/python/python-module/python-module.test.js +++ b/tests/runtimes/python/python-module/python-module.test.js @@ -1,18 +1,15 @@ import assert from 'node:assert' import { platform } from 'node:os' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import fetch from 'node-fetch' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Python 3 tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/runtimes/python/python3/python3.test.js b/tests/runtimes/python/python3/python3.test.js index cef25cc97..67c0177c4 100644 --- a/tests/runtimes/python/python3/python3.test.js +++ b/tests/runtimes/python/python3/python3.test.js @@ -1,17 +1,14 @@ import assert from 'node:assert' import { platform } from 'node:os' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Python 3 tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/runtimes/ruby/ruby.test.js b/tests/runtimes/ruby/ruby.test.js index c2e22b9c9..9d5949127 100644 --- a/tests/runtimes/ruby/ruby.test.js +++ b/tests/runtimes/ruby/ruby.test.js @@ -1,16 +1,13 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../_testHelpers/index.js' import { BASE_URL } from '../../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('Ruby tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), ) diff --git a/tests/scenario/docker/docker-in-docker/docker-in-docker.test.js b/tests/scenario/docker/docker-in-docker/docker-in-docker.test.js index b98c83b4c..4efbe8d84 100644 --- a/tests/scenario/docker/docker-in-docker/docker-in-docker.test.js +++ b/tests/scenario/docker/docker-in-docker/docker-in-docker.test.js @@ -1,20 +1,17 @@ import assert from 'node:assert' import { platform, userInfo } from 'node:os' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { execa } from 'execa' import { compressArtifact } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' import installNpmModules from '../../../installNpmModules.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('docker in docker', function desc() { const { uid, gid } = userInfo() before(async () => { - await installNpmModules(resolve(__dirname, 'app')) + await installNpmModules(join(import.meta.url, 'app')) }) beforeEach(async () => { @@ -22,10 +19,10 @@ describe('docker in docker', function desc() { return Promise.resolve() } await Promise.all([ - compressArtifact(resolve(__dirname, 'app'), 'artifacts/hello.zip', [ + compressArtifact(join(import.meta.url, 'app'), 'artifacts/hello.zip', [ 'handler.js', ]), - compressArtifact(resolve(__dirname, 'app'), 'artifacts/layer.zip', [ + compressArtifact(join(import.meta.url, 'app'), 'artifacts/layer.zip', [ 'handler.sh', ]), ]) @@ -36,7 +33,7 @@ describe('docker in docker', function desc() { } const composeEnv = { - HOST_SERVICE_PATH: resolve(__dirname, 'app'), + HOST_SERVICE_PATH: join(import.meta.url, 'app'), } if (platform() === 'windows') { // https://github.com/docker/for-win/issues/1829 @@ -48,7 +45,7 @@ describe('docker in docker', function desc() { const composeProcess = execa('docker-compose', [...composeFileArgs, 'up'], { all: true, - cwd: resolve(__dirname, 'app'), + cwd: join(import.meta.url, 'app'), env: composeEnv, }) @@ -68,7 +65,7 @@ describe('docker in docker', function desc() { return Promise.resolve() } return execa('docker-compose', ['down'], { - cwd: resolve(__dirname, 'app'), + cwd: join(import.meta.url, 'app'), }) }) diff --git a/tests/scenario/docker/docker-serverless-webpack/docker-serverless-webpack.test.js b/tests/scenario/docker/docker-serverless-webpack/docker-serverless-webpack.test.js index f708a0515..5886bb7a6 100644 --- a/tests/scenario/docker/docker-serverless-webpack/docker-serverless-webpack.test.js +++ b/tests/scenario/docker/docker-serverless-webpack/docker-serverless-webpack.test.js @@ -1,21 +1,18 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' import installNpmModules from '../../../installNpmModules.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('docker and serverless-webpack', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'app')) + await installNpmModules(join(import.meta.url, 'app')) }) beforeEach(async () => { await setup({ - servicePath: resolve(__dirname, 'app'), + servicePath: join(import.meta.url, 'app'), }) }) diff --git a/tests/scenario/lambda-frameworks/apollo-federation-supergraph/apollo-federation-supergraph.test.js b/tests/scenario/lambda-frameworks/apollo-federation-supergraph/apollo-federation-supergraph.test.js index e93c7d819..ce0aad30e 100644 --- a/tests/scenario/lambda-frameworks/apollo-federation-supergraph/apollo-federation-supergraph.test.js +++ b/tests/scenario/lambda-frameworks/apollo-federation-supergraph/apollo-federation-supergraph.test.js @@ -1,22 +1,19 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' import installNpmModules from '../../../installNpmModules.js' const { stringify } = JSON -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('apollo federation supergraph', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'app')) + await installNpmModules(join(import.meta.url, 'app')) }) beforeEach(async () => { await setup({ - servicePath: resolve(__dirname, 'app'), + servicePath: join(import.meta.url, 'app'), }) }) diff --git a/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/gateway/src/index.js b/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/gateway/src/index.js index 03eb7d28a..8f2219c77 100755 --- a/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/gateway/src/index.js +++ b/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/gateway/src/index.js @@ -1,15 +1,13 @@ import { readFile } from 'node:fs/promises' -import { dirname, join, resolve } from 'node:path' +import { join as pathJoin } from 'node:path' import { env } from 'node:process' -import { fileURLToPath } from 'node:url' import { ApolloGateway, RemoteGraphQLDataSource } from '@apollo/gateway' import { ApolloServer } from '@apollo/server' import { startServerAndCreateLambdaHandler } from '@as-integrations/aws-lambda' - -const __dirname = dirname(fileURLToPath(import.meta.url)) +import { join } from 'desm' const schema = await readFile( - resolve(__dirname, '../schema/supergraph-gateway.graphql'), + join(import.meta.url, '../schema/supergraph-gateway.graphql'), 'utf8', ) @@ -18,7 +16,7 @@ const gateway = new ApolloGateway({ const { name, url } = definition // TEMNP, we should probably always use env.API_GATEWAY? - const remoteUrl = join(env.IS_OFFLINE ? url : env.APIGATEWAY_URL, name) + const remoteUrl = pathJoin(env.IS_OFFLINE ? url : env.APIGATEWAY_URL, name) return new RemoteGraphQLDataSource({ url: remoteUrl, diff --git a/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/inventory/src/index.js b/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/inventory/src/index.js index 98bb3f132..c494844d2 100755 --- a/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/inventory/src/index.js +++ b/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/inventory/src/index.js @@ -1,16 +1,13 @@ import { readFile } from 'node:fs/promises' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' import { ApolloServer } from '@apollo/server' import { buildSubgraphSchema } from '@apollo/subgraph' import { startServerAndCreateLambdaHandler } from '@as-integrations/aws-lambda' +import { join } from 'desm' import gql from 'graphql-tag' import resolvers from './resolvers.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - const schema = await readFile( - resolve(__dirname, '../schema/inventory.graphql'), + join(import.meta.url, '../schema/inventory.graphql'), 'utf8', ) diff --git a/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/products/src/index.js b/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/products/src/index.js index 8c956a6db..005107669 100755 --- a/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/products/src/index.js +++ b/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/products/src/index.js @@ -1,16 +1,13 @@ import { readFile } from 'node:fs/promises' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' import { ApolloServer } from '@apollo/server' import { buildSubgraphSchema } from '@apollo/subgraph' import { startServerAndCreateLambdaHandler } from '@as-integrations/aws-lambda' +import { join } from 'desm' import gql from 'graphql-tag' import resolvers from './resolvers.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - const schema = await readFile( - resolve(__dirname, '../schema/products.graphql'), + join(import.meta.url, '../schema/products.graphql'), 'utf8', ) diff --git a/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/users/src/index.js b/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/users/src/index.js index f4624c808..6ad7c108b 100755 --- a/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/users/src/index.js +++ b/tests/scenario/lambda-frameworks/apollo-federation-supergraph/app/users/src/index.js @@ -1,16 +1,13 @@ import { readFile } from 'node:fs/promises' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { ApolloServer } from '@apollo/server' import { buildSubgraphSchema } from '@apollo/subgraph' import { startServerAndCreateLambdaHandler } from '@as-integrations/aws-lambda' import gql from 'graphql-tag' import resolvers from './resolvers.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - const schema = await readFile( - resolve(__dirname, '../schema/users.graphql'), + join(import.meta.url, '../schema/users.graphql'), 'utf8', ) diff --git a/tests/scenario/lambda-frameworks/apollo-server-integrations/apollo-server-integrations.test.js b/tests/scenario/lambda-frameworks/apollo-server-integrations/apollo-server-integrations.test.js index 8ce522aa6..2dd014d81 100644 --- a/tests/scenario/lambda-frameworks/apollo-server-integrations/apollo-server-integrations.test.js +++ b/tests/scenario/lambda-frameworks/apollo-server-integrations/apollo-server-integrations.test.js @@ -1,22 +1,19 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' import installNpmModules from '../../../installNpmModules.js' const { stringify } = JSON -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('apollo server integrations', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'app')) + await installNpmModules(join(import.meta.url, 'app')) }) beforeEach(async () => { await setup({ - servicePath: resolve(__dirname, 'app'), + servicePath: join(import.meta.url, 'app'), }) }) diff --git a/tests/scenario/lambda-frameworks/middy-lambda/middy-lambda.test.js b/tests/scenario/lambda-frameworks/middy-lambda/middy-lambda.test.js index bf30140bb..0539bc32d 100644 --- a/tests/scenario/lambda-frameworks/middy-lambda/middy-lambda.test.js +++ b/tests/scenario/lambda-frameworks/middy-lambda/middy-lambda.test.js @@ -1,22 +1,19 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' import installNpmModules from '../../../installNpmModules.js' const { stringify } = JSON -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('middy with lambda', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'app')) + await installNpmModules(join(import.meta.url, 'app')) }) beforeEach(async () => { await setup({ - servicePath: resolve(__dirname, 'app'), + servicePath: join(import.meta.url, 'app'), }) }) diff --git a/tests/scenario/lambda-frameworks/serverless-http-with-express/serverless-http-with-express.test.js b/tests/scenario/lambda-frameworks/serverless-http-with-express/serverless-http-with-express.test.js index cf8e17eb9..7a4fb0ce7 100644 --- a/tests/scenario/lambda-frameworks/serverless-http-with-express/serverless-http-with-express.test.js +++ b/tests/scenario/lambda-frameworks/serverless-http-with-express/serverless-http-with-express.test.js @@ -1,22 +1,19 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' import installNpmModules from '../../../installNpmModules.js' const { stringify } = JSON -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('serverless-http with express', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'app')) + await installNpmModules(join(import.meta.url, 'app')) }) beforeEach(async () => { await setup({ - servicePath: resolve(__dirname, 'app'), + servicePath: join(import.meta.url, 'app'), }) }) diff --git a/tests/scenario/lambda-frameworks/sparticuz-chrome-aws-lambda/sparticuz-chrome-aws-lambda-http-api.test.js b/tests/scenario/lambda-frameworks/sparticuz-chrome-aws-lambda/sparticuz-chrome-aws-lambda-http-api.test.js index e6b6c3231..c14b7faae 100644 --- a/tests/scenario/lambda-frameworks/sparticuz-chrome-aws-lambda/sparticuz-chrome-aws-lambda-http-api.test.js +++ b/tests/scenario/lambda-frameworks/sparticuz-chrome-aws-lambda/sparticuz-chrome-aws-lambda-http-api.test.js @@ -1,21 +1,18 @@ import assert from 'node:assert' import { platform } from 'node:os' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' import installNpmModules from '../../../installNpmModules.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('@sparticuz/chrome-aws-lambda http api', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'app-http-api')) + await installNpmModules(join(import.meta.url, 'app-http-api')) }) beforeEach(async () => { await setup({ - servicePath: resolve(__dirname, 'app-http-api'), + servicePath: join(import.meta.url, 'app-http-api'), }) }) diff --git a/tests/scenario/lambda-frameworks/sparticuz-chrome-aws-lambda/sparticuz-chrome-aws-lambda-http.test.js b/tests/scenario/lambda-frameworks/sparticuz-chrome-aws-lambda/sparticuz-chrome-aws-lambda-http.test.js index 3f51ca938..bc6212c1c 100644 --- a/tests/scenario/lambda-frameworks/sparticuz-chrome-aws-lambda/sparticuz-chrome-aws-lambda-http.test.js +++ b/tests/scenario/lambda-frameworks/sparticuz-chrome-aws-lambda/sparticuz-chrome-aws-lambda-http.test.js @@ -1,21 +1,18 @@ import assert from 'node:assert' import { platform } from 'node:os' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' import installNpmModules from '../../../installNpmModules.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('@sparticuz/chrome-aws-lambda http', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'app-http')) + await installNpmModules(join(import.meta.url, 'app-http')) }) beforeEach(async () => { await setup({ - servicePath: resolve(__dirname, 'app-http'), + servicePath: join(import.meta.url, 'app-http'), }) }) diff --git a/tests/scenario/lambda-frameworks/vendia-serverless-express/vendia-serverless-express.test.js b/tests/scenario/lambda-frameworks/vendia-serverless-express/vendia-serverless-express.test.js index 5698bc052..f6c40a964 100644 --- a/tests/scenario/lambda-frameworks/vendia-serverless-express/vendia-serverless-express.test.js +++ b/tests/scenario/lambda-frameworks/vendia-serverless-express/vendia-serverless-express.test.js @@ -1,24 +1,21 @@ import assert from 'node:assert' import { Buffer } from 'node:buffer' import { readFile } from 'node:fs/promises' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' import installNpmModules from '../../../installNpmModules.js' const { stringify } = JSON -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('@vendia/serverless-express', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'app')) + await installNpmModules(join(import.meta.url, 'app')) }) beforeEach(async () => { await setup({ - servicePath: resolve(__dirname, 'app'), + servicePath: join(import.meta.url, 'app'), }) }) @@ -77,8 +74,7 @@ describe('@vendia/serverless-express', function desc() { const response = await fetch(url) const arrayBuffer = await response.arrayBuffer() const buffer = Buffer.from(arrayBuffer) - - const image = await readFile(resolve(__dirname, 'app/src/sam-logo.png')) + const image = await readFile(join(import.meta.url, 'app/src/sam-logo.png')) assert.equal(response.status, 200) assert.deepEqual(buffer, image) diff --git a/tests/scenario/serverless-plugins/serverless-esbuild/serverless-esbuild.test.js b/tests/scenario/serverless-plugins/serverless-esbuild/serverless-esbuild.test.js index de0872f6d..7918194c0 100644 --- a/tests/scenario/serverless-plugins/serverless-esbuild/serverless-esbuild.test.js +++ b/tests/scenario/serverless-plugins/serverless-esbuild/serverless-esbuild.test.js @@ -1,20 +1,17 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' import installNpmModules from '../../../installNpmModules.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('serverless-esbuild', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'app')) + await installNpmModules(join(import.meta.url, 'app')) }) beforeEach(async () => { await setup({ - servicePath: resolve(__dirname, 'app'), + servicePath: join(import.meta.url, 'app'), }) }) diff --git a/tests/scenario/serverless-plugins/serverless-plugin-typescript/serverless-plugin-typescript.test.js b/tests/scenario/serverless-plugins/serverless-plugin-typescript/serverless-plugin-typescript.test.js index 7f53a1ef9..ca1f5df1e 100644 --- a/tests/scenario/serverless-plugins/serverless-plugin-typescript/serverless-plugin-typescript.test.js +++ b/tests/scenario/serverless-plugins/serverless-plugin-typescript/serverless-plugin-typescript.test.js @@ -1,20 +1,17 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' import installNpmModules from '../../../installNpmModules.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('serverless-plugin-typescript', function desc() { before(async () => { - await installNpmModules(resolve(__dirname, 'app')) + await installNpmModules(join(import.meta.url, 'app')) }) beforeEach(async () => { await setup({ - servicePath: resolve(__dirname, 'app'), + servicePath: join(import.meta.url, 'app'), }) }) diff --git a/tests/scenario/serverless-plugins/serverless-webpack/serverless-webpack.test.js b/tests/scenario/serverless-plugins/serverless-webpack/serverless-webpack.test.js index e29b88da6..ce4a55ac4 100644 --- a/tests/scenario/serverless-plugins/serverless-webpack/serverless-webpack.test.js +++ b/tests/scenario/serverless-plugins/serverless-webpack/serverless-webpack.test.js @@ -1,20 +1,17 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../../../_testHelpers/index.js' import { BASE_URL } from '../../../config.js' import installNpmModules from '../../../installNpmModules.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('serverless-webpack', function describe() { before(async () => { - await installNpmModules(resolve(__dirname, 'app')) + await installNpmModules(join(import.meta.url, 'app')) }) beforeEach(async () => { await setup({ - servicePath: resolve(__dirname, 'app'), + servicePath: join(import.meta.url, 'app'), }) }) diff --git a/tests/timeout/timeout.test.js b/tests/timeout/timeout.test.js index 4f771406c..28c97eb5f 100644 --- a/tests/timeout/timeout.test.js +++ b/tests/timeout/timeout.test.js @@ -1,15 +1,12 @@ import assert from 'node:assert' -import { dirname, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'desm' import { setup, teardown } from '../_testHelpers/index.js' import { BASE_URL } from '../config.js' -const __dirname = dirname(fileURLToPath(import.meta.url)) - describe('handler payload tests', function desc() { beforeEach(() => setup({ - servicePath: resolve(__dirname), + servicePath: join(import.meta.url), }), )