From 033aae6e914f2910e3c624e289702b9c8aa2023a Mon Sep 17 00:00:00 2001 From: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com> Date: Mon, 9 May 2022 08:59:40 -0700 Subject: [PATCH 1/3] feat: nodejs16 (#29) * Nodejs16 support for samcli * Format test_nodejs_npm.py and test_nodejs_npm_with_esbuild.py using black * Use parameterized instead of runtimes list Co-authored-by: Aboelhamd Mahmoud --- aws_lambda_builders/validator.py | 1 + .../workflows/nodejs_npm/test_nodejs_npm.py | 72 ++++++++++++------- .../test_nodejs_npm_with_esbuild.py | 64 ++++++++++------- 3 files changed, 87 insertions(+), 50 deletions(-) diff --git a/aws_lambda_builders/validator.py b/aws_lambda_builders/validator.py index db1073532..cea30a2aa 100644 --- a/aws_lambda_builders/validator.py +++ b/aws_lambda_builders/validator.py @@ -13,6 +13,7 @@ SUPPORTED_RUNTIMES = { "nodejs12.x": [ARM64, X86_64], "nodejs14.x": [ARM64, X86_64], + "nodejs16.x": [ARM64, X86_64], "python3.6": [X86_64], "python3.7": [X86_64], "python3.8": [ARM64, X86_64], diff --git a/tests/integration/workflows/nodejs_npm/test_nodejs_npm.py b/tests/integration/workflows/nodejs_npm/test_nodejs_npm.py index f11adec6c..99e3e8e6e 100644 --- a/tests/integration/workflows/nodejs_npm/test_nodejs_npm.py +++ b/tests/integration/workflows/nodejs_npm/test_nodejs_npm.py @@ -29,14 +29,14 @@ def setUp(self): self.no_deps = os.path.join(self.TEST_DATA_FOLDER, "no-deps") self.builder = LambdaBuilder(language="nodejs", dependency_manager="npm", application_framework=None) - self.runtime = "nodejs12.x" def tearDown(self): shutil.rmtree(self.artifacts_dir) shutil.rmtree(self.scratch_dir) shutil.rmtree(self.dependencies_dir) - def test_builds_project_without_dependencies(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_project_without_dependencies(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "no-deps") self.builder.build( @@ -44,14 +44,15 @@ def test_builds_project_without_dependencies(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, ) expected_files = {"package.json", "included.js"} output_files = set(os.listdir(self.artifacts_dir)) self.assertEqual(expected_files, output_files) - def test_builds_project_without_manifest(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_project_without_manifest(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "no-manifest") with mock.patch.object(logger, "warning") as mock_warning: @@ -60,7 +61,7 @@ def test_builds_project_without_manifest(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, ) expected_files = {"app.js"} @@ -68,7 +69,8 @@ def test_builds_project_without_manifest(self): mock_warning.assert_called_once_with("package.json file not found. Continuing the build without dependencies.") self.assertEqual(expected_files, output_files) - def test_builds_project_and_excludes_hidden_aws_sam(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_project_and_excludes_hidden_aws_sam(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "excluded-files") self.builder.build( @@ -76,14 +78,15 @@ def test_builds_project_and_excludes_hidden_aws_sam(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, ) expected_files = {"package.json", "included.js"} output_files = set(os.listdir(self.artifacts_dir)) self.assertEqual(expected_files, output_files) - def test_builds_project_with_remote_dependencies(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_project_with_remote_dependencies(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "npm-deps") self.builder.build( @@ -91,7 +94,7 @@ def test_builds_project_with_remote_dependencies(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, ) expected_files = {"package.json", "included.js", "node_modules"} @@ -102,7 +105,8 @@ def test_builds_project_with_remote_dependencies(self): output_modules = set(os.listdir(os.path.join(self.artifacts_dir, "node_modules"))) self.assertEqual(expected_modules, output_modules) - def test_builds_project_with_npmrc(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_project_with_npmrc(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "npmrc") self.builder.build( @@ -110,7 +114,7 @@ def test_builds_project_with_npmrc(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, ) expected_files = {"package.json", "included.js", "node_modules"} @@ -122,8 +126,20 @@ def test_builds_project_with_npmrc(self): output_modules = set(os.listdir(os.path.join(self.artifacts_dir, "node_modules"))) self.assertEqual(expected_modules, output_modules) - @parameterized.expand(["package-lock", "shrinkwrap", "package-lock-and-shrinkwrap"]) - def test_builds_project_with_lockfile(self, dir_name): + @parameterized.expand( + [ + ("nodejs12.x", "package-lock"), + ("nodejs14.x", "package-lock"), + ("nodejs16.x", "package-lock"), + ("nodejs12.x", "shrinkwrap"), + ("nodejs14.x", "shrinkwrap"), + ("nodejs16.x", "shrinkwrap"), + ("nodejs12.x", "package-lock-and-shrinkwrap"), + ("nodejs14.x", "package-lock-and-shrinkwrap"), + ("nodejs16.x", "package-lock-and-shrinkwrap"), + ] + ) + def test_builds_project_with_lockfile(self, runtime, dir_name): expected_files_common = {"package.json", "included.js", "node_modules"} expected_files_by_dir_name = { "package-lock": {"package-lock.json"}, @@ -138,7 +154,7 @@ def test_builds_project_with_lockfile(self, dir_name): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, ) expected_files = expected_files_common.union(expected_files_by_dir_name[dir_name]) @@ -147,8 +163,8 @@ def test_builds_project_with_lockfile(self, dir_name): self.assertEqual(expected_files, output_files) - def test_fails_if_npm_cannot_resolve_dependencies(self): - + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_fails_if_npm_cannot_resolve_dependencies(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "broken-deps") with self.assertRaises(WorkflowFailedError) as ctx: @@ -157,12 +173,13 @@ def test_fails_if_npm_cannot_resolve_dependencies(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, ) self.assertIn("No matching version found for aws-sdk@2.997.999", str(ctx.exception)) - def test_builds_project_with_remote_dependencies_without_download_dependencies_with_dependencies_dir(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_project_with_remote_dependencies_without_download_dependencies_with_dependencies_dir(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "npm-deps") self.builder.build( @@ -170,7 +187,7 @@ def test_builds_project_with_remote_dependencies_without_download_dependencies_w self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, dependencies_dir=self.dependencies_dir, download_dependencies=False, ) @@ -179,7 +196,8 @@ def test_builds_project_with_remote_dependencies_without_download_dependencies_w output_files = set(os.listdir(self.artifacts_dir)) self.assertEqual(expected_files, output_files) - def test_builds_project_with_remote_dependencies_with_download_dependencies_and_dependencies_dir(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_project_with_remote_dependencies_with_download_dependencies_and_dependencies_dir(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "npm-deps") self.builder.build( @@ -187,7 +205,7 @@ def test_builds_project_with_remote_dependencies_with_download_dependencies_and_ self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, dependencies_dir=self.dependencies_dir, download_dependencies=True, ) @@ -208,7 +226,10 @@ def test_builds_project_with_remote_dependencies_with_download_dependencies_and_ output_dependencies_files = set(os.listdir(os.path.join(self.dependencies_dir))) self.assertNotIn(expected_dependencies_files, output_dependencies_files) - def test_builds_project_with_remote_dependencies_without_download_dependencies_without_dependencies_dir(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_project_with_remote_dependencies_without_download_dependencies_without_dependencies_dir( + self, runtime + ): source_dir = os.path.join(self.TEST_DATA_FOLDER, "npm-deps") with mock.patch.object(logger, "info") as mock_info: @@ -217,7 +238,7 @@ def test_builds_project_with_remote_dependencies_without_download_dependencies_w self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, dependencies_dir=None, download_dependencies=False, ) @@ -231,7 +252,8 @@ def test_builds_project_with_remote_dependencies_without_download_dependencies_w "artifacts directory. " ) - def test_builds_project_without_combine_dependencies(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_project_without_combine_dependencies(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "npm-deps") self.builder.build( @@ -239,7 +261,7 @@ def test_builds_project_without_combine_dependencies(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, dependencies_dir=self.dependencies_dir, download_dependencies=True, combine_dependencies=False, diff --git a/tests/integration/workflows/nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py b/tests/integration/workflows/nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py index 90c8c364d..c4dce621f 100644 --- a/tests/integration/workflows/nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py +++ b/tests/integration/workflows/nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py @@ -8,6 +8,7 @@ from aws_lambda_builders.workflows.nodejs_npm.utils import OSUtils from aws_lambda_builders.workflows.nodejs_npm_esbuild.esbuild import EsbuildExecutionError from aws_lambda_builders.workflows.nodejs_npm_esbuild.utils import EXPERIMENTAL_FLAG_ESBUILD +from parameterized import parameterized class TestNodejsNpmWorkflowWithEsbuild(TestCase): @@ -25,13 +26,13 @@ def setUp(self): self.no_deps = os.path.join(self.TEST_DATA_FOLDER, "no-deps-esbuild") self.builder = LambdaBuilder(language="nodejs", dependency_manager="npm-esbuild", application_framework=None) - self.runtime = "nodejs14.x" def tearDown(self): shutil.rmtree(self.artifacts_dir) shutil.rmtree(self.scratch_dir) - def test_doesnt_build_without_feature_flag(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_doesnt_build_without_feature_flag(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "with-deps-esbuild") with self.assertRaises(EsbuildExecutionError) as context: @@ -40,11 +41,12 @@ def test_doesnt_build_without_feature_flag(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, ) self.assertEqual(str(context.exception), "Esbuild Failed: Feature flag must be enabled to use this workflow") - def test_builds_javascript_project_with_dependencies(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_javascript_project_with_dependencies(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "with-deps-esbuild") options = {"entry_points": ["included.js"]} @@ -54,7 +56,7 @@ def test_builds_javascript_project_with_dependencies(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, options=options, experimental_flags=[EXPERIMENTAL_FLAG_ESBUILD], ) @@ -63,7 +65,8 @@ def test_builds_javascript_project_with_dependencies(self): output_files = set(os.listdir(self.artifacts_dir)) self.assertEqual(expected_files, output_files) - def test_builds_javascript_project_with_multiple_entrypoints(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_javascript_project_with_multiple_entrypoints(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "with-deps-esbuild-multiple-entrypoints") options = {"entry_points": ["included.js", "included2.js"]} @@ -73,7 +76,7 @@ def test_builds_javascript_project_with_multiple_entrypoints(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, options=options, experimental_flags=[EXPERIMENTAL_FLAG_ESBUILD], ) @@ -82,7 +85,8 @@ def test_builds_javascript_project_with_multiple_entrypoints(self): output_files = set(os.listdir(self.artifacts_dir)) self.assertEqual(expected_files, output_files) - def test_builds_typescript_projects(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_typescript_projects(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "with-deps-esbuild-typescript") options = {"entry_points": ["included.ts"]} @@ -92,7 +96,7 @@ def test_builds_typescript_projects(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, options=options, experimental_flags=[EXPERIMENTAL_FLAG_ESBUILD], ) @@ -101,7 +105,8 @@ def test_builds_typescript_projects(self): output_files = set(os.listdir(self.artifacts_dir)) self.assertEqual(expected_files, output_files) - def test_builds_with_external_esbuild(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_with_external_esbuild(self, runtime): osutils = OSUtils() npm = SubprocessNpm(osutils) source_dir = os.path.join(self.TEST_DATA_FOLDER, "no-deps-esbuild") @@ -118,7 +123,7 @@ def test_builds_with_external_esbuild(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, options=options, executable_search_paths=[binpath], experimental_flags=[EXPERIMENTAL_FLAG_ESBUILD], @@ -128,7 +133,8 @@ def test_builds_with_external_esbuild(self): output_files = set(os.listdir(self.artifacts_dir)) self.assertEqual(expected_files, output_files) - def test_no_options_passed_to_esbuild(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_no_options_passed_to_esbuild(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "with-deps-esbuild") with self.assertRaises(WorkflowFailedError) as context: @@ -137,13 +143,14 @@ def test_no_options_passed_to_esbuild(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, experimental_flags=[EXPERIMENTAL_FLAG_ESBUILD], ) self.assertEqual(str(context.exception), "NodejsNpmEsbuildBuilder:EsbuildBundle - entry_points not set ({})") - def test_bundle_with_implicit_file_types(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_bundle_with_implicit_file_types(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "implicit-file-types") options = {"entry_points": ["included", "implicit"]} @@ -153,7 +160,7 @@ def test_bundle_with_implicit_file_types(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, options=options, experimental_flags=[EXPERIMENTAL_FLAG_ESBUILD], ) @@ -162,7 +169,8 @@ def test_bundle_with_implicit_file_types(self): output_files = set(os.listdir(self.artifacts_dir)) self.assertEqual(expected_files, output_files) - def test_bundles_project_without_dependencies(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_bundles_project_without_dependencies(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "no-package-esbuild") options = {"entry_points": ["included"]} @@ -177,7 +185,7 @@ def test_bundles_project_without_dependencies(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, options=options, experimental_flags=[EXPERIMENTAL_FLAG_ESBUILD], executable_search_paths=[binpath], @@ -187,7 +195,8 @@ def test_bundles_project_without_dependencies(self): output_files = set(os.listdir(self.artifacts_dir)) self.assertEqual(expected_files, output_files) - def test_builds_project_with_remote_dependencies_without_download_dependencies_with_dependencies_dir(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_project_with_remote_dependencies_without_download_dependencies_with_dependencies_dir(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "with-deps-no-node_modules") options = {"entry_points": ["included.js"]} @@ -203,7 +212,7 @@ def test_builds_project_with_remote_dependencies_without_download_dependencies_w self.scratch_dir, os.path.join(source_dir, "package.json"), options=options, - runtime=self.runtime, + runtime=runtime, dependencies_dir=self.dependencies_dir, download_dependencies=False, experimental_flags=[EXPERIMENTAL_FLAG_ESBUILD], @@ -214,7 +223,8 @@ def test_builds_project_with_remote_dependencies_without_download_dependencies_w output_files = set(os.listdir(self.artifacts_dir)) self.assertEqual(expected_files, output_files) - def test_builds_project_with_remote_dependencies_with_download_dependencies_and_dependencies_dir(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_project_with_remote_dependencies_with_download_dependencies_and_dependencies_dir(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "with-deps-no-node_modules") options = {"entry_points": ["included.js"]} @@ -223,7 +233,7 @@ def test_builds_project_with_remote_dependencies_with_download_dependencies_and_ self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, options=options, dependencies_dir=self.dependencies_dir, download_dependencies=True, @@ -242,7 +252,10 @@ def test_builds_project_with_remote_dependencies_with_download_dependencies_and_ output_dependencies_files = set(os.listdir(os.path.join(self.dependencies_dir))) self.assertNotIn(expected_dependencies_files, output_dependencies_files) - def test_builds_project_with_remote_dependencies_without_download_dependencies_without_dependencies_dir(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_project_with_remote_dependencies_without_download_dependencies_without_dependencies_dir( + self, runtime + ): source_dir = os.path.join(self.TEST_DATA_FOLDER, "with-deps-no-node_modules") with self.assertRaises(EsbuildExecutionError) as context: @@ -251,7 +264,7 @@ def test_builds_project_with_remote_dependencies_without_download_dependencies_w self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, dependencies_dir=None, download_dependencies=False, experimental_flags=[EXPERIMENTAL_FLAG_ESBUILD], @@ -259,7 +272,8 @@ def test_builds_project_with_remote_dependencies_without_download_dependencies_w self.assertEqual(str(context.exception), "Esbuild Failed: Lambda Builders encountered and invalid workflow") - def test_builds_project_without_combine_dependencies(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_project_without_combine_dependencies(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "with-deps-no-node_modules") options = {"entry_points": ["included.js"]} @@ -268,7 +282,7 @@ def test_builds_project_without_combine_dependencies(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, options=options, dependencies_dir=self.dependencies_dir, download_dependencies=True, From cbc2e29775583a99fff5e80aedc01d96ddaa0b6c Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Mon, 9 May 2022 09:29:52 -0700 Subject: [PATCH 2/3] Fix new tests --- .../nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/integration/workflows/nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py b/tests/integration/workflows/nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py index 7b27d2b7f..93daff895 100644 --- a/tests/integration/workflows/nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py +++ b/tests/integration/workflows/nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py @@ -302,7 +302,8 @@ def test_builds_project_without_combine_dependencies(self, runtime): output_dependencies_files = set(os.listdir(os.path.join(self.dependencies_dir))) self.assertNotIn(expected_dependencies_files, output_dependencies_files) - def test_builds_javascript_project_with_external(self): + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) + def test_builds_javascript_project_with_external(self, runtime): source_dir = os.path.join(self.TEST_DATA_FOLDER, "with-deps-esbuild-externals") options = {"entry_points": ["included.js"], "external": ["minimal-request-promise"]} @@ -312,7 +313,7 @@ def test_builds_javascript_project_with_external(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, options=options, experimental_flags=[EXPERIMENTAL_FLAG_ESBUILD], ) @@ -325,6 +326,7 @@ def test_builds_javascript_project_with_external(self): # Check that the module has been require() instead of bundled self.assertIn('require("minimal-request-promise")', js_file) + @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) def test_builds_javascript_project_with_loader(self): osutils = OSUtils() source_dir = os.path.join(self.TEST_DATA_FOLDER, "no-deps-esbuild-loader") @@ -336,7 +338,7 @@ def test_builds_javascript_project_with_loader(self): self.artifacts_dir, self.scratch_dir, os.path.join(source_dir, "package.json"), - runtime=self.runtime, + runtime=runtime, options=options, experimental_flags=[EXPERIMENTAL_FLAG_ESBUILD], ) From 1c6f6c49404e3e01d9f7be45957b1adfd45227b7 Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Mon, 9 May 2022 09:45:16 -0700 Subject: [PATCH 3/3] Fix test --- .../nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/workflows/nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py b/tests/integration/workflows/nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py index 93daff895..38448a990 100644 --- a/tests/integration/workflows/nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py +++ b/tests/integration/workflows/nodejs_npm_esbuild/test_nodejs_npm_with_esbuild.py @@ -327,7 +327,7 @@ def test_builds_javascript_project_with_external(self, runtime): self.assertIn('require("minimal-request-promise")', js_file) @parameterized.expand([("nodejs12.x",), ("nodejs14.x",), ("nodejs16.x",)]) - def test_builds_javascript_project_with_loader(self): + def test_builds_javascript_project_with_loader(self, runtime): osutils = OSUtils() source_dir = os.path.join(self.TEST_DATA_FOLDER, "no-deps-esbuild-loader")