From ba27f9a0e37bf3bf94619d0362b07545b21b15c4 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Mon, 13 May 2019 15:30:18 -0400 Subject: [PATCH 01/23] add integration tests using `sls package` Just the beginning. a few simple file inclusion tests and a cfn tempalte test closes #5938 --- .travis.yml | 2 +- package.json | 1 + tests/local-suite/packaging.tests.js | 119 +++++++++++++++++++++++++++ tests/utils/index.js | 5 ++ 4 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 tests/local-suite/packaging.tests.js diff --git a/.travis.yml b/.travis.yml index 3bf161084..a7fd54d22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ sudo: false install: - travis_retry npm install script: -- if [[ -z "$INTEGRATION_TEST" && -z "$DISABLE_TESTS" ]]; then npm test; fi +- if [[ -z "$INTEGRATION_TEST" && -z "$DISABLE_TESTS" ]]; then npm test && npm local-integration-test; fi - if [[ ! -z "$DISABLE_TESTS" && ! -z "$LINTING" && -z "$INTEGRATION_TEST" ]]; then npm run lint; fi - if [[ ! -z "$INTEGRATION_TEST" && ! -z ${AWS_ACCESS_KEY_ID+x} && "$INTEGRATION_TEST_SUITE" diff --git a/package.json b/package.json index f179fb8d9..147caab8e 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "lint": "eslint . --cache", "docs": "node scripts/generate-readme.js", "integration-test-cleanup": "node scripts/integration-test-cleanup.js", + "local-integration-test": "jest --maxWorkers=5 local-suite", "simple-integration-test": "jest --maxWorkers=5 simple-suite", "complex-integration-test": "jest --maxWorkers=5 integration", "postinstall": "node ./scripts/postinstall.js" diff --git a/tests/local-suite/packaging.tests.js b/tests/local-suite/packaging.tests.js new file mode 100644 index 000000000..17f75af1e --- /dev/null +++ b/tests/local-suite/packaging.tests.js @@ -0,0 +1,119 @@ +const fs = require('fs'); +const path = require('path'); +const execSync = require('child_process').execSync; +const BbPromise = require('bluebird'); +const fse = require('fs-extra'); +const testUtils = require('../utils/index'); + +const serverlessExec = path.join(__dirname, '..', '..', 'bin', 'serverless'); + +describe('simple packaging', () => { + let cwd + beforeEach(() => { + cwd = testUtils.getTmpDirPath(); + fse.mkdirsSync(cwd); + }) + + it('packages the default aws template correctly', () => { + const templateName = 'aws-nodejs'; + execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); + execSync(`${serverlessExec} package`, { cwd }); + return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) + .then(zipfiles => { + expect(zipfiles).toEqual(['handler.js']); + }); + }) + + it('packages the default aws template with an npm dep correctly', () => { + const templateName = 'aws-nodejs'; + execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); + execSync(`npm init --yes`, { cwd }); + execSync(`npm i lodash`, { cwd }); + execSync(`${serverlessExec} package`, { cwd }); + return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) + .then(zipfiles => { + const nodeModules = new Set(zipfiles.filter(f => f.startsWith('node_modules')).map(f => f.split(path.sep)[1])); + const nonNodeModulesFiles = zipfiles.filter(f => !f.startsWith('node_modules')); + expect(nodeModules).toEqual(new Set(['lodash'])); + expect(nonNodeModulesFiles).toEqual(['handler.js', 'package-lock.json', 'package.json']); + }); + }) + + it('doesn\'t package a dev dependency', () => { + const templateName = 'aws-nodejs'; + execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); + execSync(`npm init --yes`, { cwd }); + execSync(`npm i --save-dev lodash`, { cwd }); + execSync(`${serverlessExec} package`, { cwd }); + return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) + .then(zipfiles => { + const nodeModules = new Set(zipfiles.filter(f => f.startsWith('node_modules')).map(f => f.split(path.sep)[1])); + const nonNodeModulesFiles = zipfiles.filter(f => !f.startsWith('node_modules')); + expect(nodeModules).toEqual(new Set([])); + expect(nonNodeModulesFiles).toEqual(['handler.js', 'package-lock.json', 'package.json']); + }); + }) + + it('ignores package json files per ignore directive', () => { + const templateName = 'aws-nodejs'; + execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); + execSync(`npm init --yes`, { cwd }); + execSync(`echo 'package: {exclude: ["package*.json"]}' >> serverless.yml`, { cwd }); + execSync(`npm i lodash`, { cwd }); + execSync(`${serverlessExec} package`, { cwd }); + return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) + .then(zipfiles => { + const nodeModules = new Set(zipfiles.filter(f => f.startsWith('node_modules')).map(f => f.split(path.sep)[1])); + const nonNodeModulesFiles = zipfiles.filter(f => !f.startsWith('node_modules')); + expect(nodeModules).toEqual(new Set(['lodash'])); + expect(nonNodeModulesFiles).toEqual(['handler.js']); + }); + }) +}) + +describe('cloudformation packaging', () => { + let cwd + beforeEach(() => { + cwd = testUtils.getTmpDirPath(); + fse.mkdirsSync(cwd); + }) + + it('creates the correct default function resource', () => { + const templateName = 'aws-nodejs'; + execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); + execSync(`${serverlessExec} package`, { cwd }); + const cfnTemplate = JSON.parse(fs.readFileSync(path.join( + cwd, '.serverless/cloudformation-template-update-stack.json'))) + expect(cfnTemplate.Resources.HelloLambdaFunction.Properties.Code.S3Key).toMatch(/serverless\/aws-nodejs\/dev\/[^]*\/aws-nodejs.zip/) + delete cfnTemplate.Resources.HelloLambdaFunction.Properties.Code.S3Key; + expect(cfnTemplate.Resources.HelloLambdaFunction).toEqual({ + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Ref": "ServerlessDeploymentBucket" + } + }, + "FunctionName": "aws-nodejs-dev-hello", + "Handler": "handler.hello", + "MemorySize": 1024, + "Role": { + "Fn::GetAtt": [ + "IamRoleLambdaExecution", + "Arn" + ] + }, + "Runtime": "nodejs8.10", + "Timeout": 6 + }, + "DependsOn": [ + "HelloLogGroup", + "IamRoleLambdaExecution" + ] + }) + return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) + .then(zipfiles => { + expect(zipfiles).toEqual(['handler.js']); + }); + }) +}) diff --git a/tests/utils/index.js b/tests/utils/index.js index 687760759..081ea7a56 100644 --- a/tests/utils/index.js +++ b/tests/utils/index.js @@ -4,6 +4,7 @@ const fs = require('fs'); const os = require('os'); const path = require('path'); const crypto = require('crypto'); +const JSZip = require('jszip'); const BbPromise = require('bluebird'); const fse = require('fs-extra'); const execSync = require('child_process').execSync; @@ -34,12 +35,16 @@ const replaceTextInFile = (filePath, subString, newSubString) => { fs.writeFileSync(filePath, fileContent.replace(subString, newSubString)); }; +const listZipFiles = filename => new JSZip().loadAsync(fs.readFileSync(filename)) + .then(zip => Object.keys(zip.files)); + module.exports = { serverlessExec, getTmpDirPath, getTmpFilePath, replaceTextInFile, ServerlessPlugin, + listZipFiles, createTestService: (templateName, testServiceDir) => { const hrtime = process.hrtime(); From a981d264f2636673ff2b949fdf7e4578e5f18e91 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Mon, 13 May 2019 15:40:33 -0400 Subject: [PATCH 02/23] delint --- tests/local-suite/packaging.tests.js | 98 ++++++++++++++-------------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/tests/local-suite/packaging.tests.js b/tests/local-suite/packaging.tests.js index 17f75af1e..f2fd0fd39 100644 --- a/tests/local-suite/packaging.tests.js +++ b/tests/local-suite/packaging.tests.js @@ -1,18 +1,17 @@ const fs = require('fs'); const path = require('path'); const execSync = require('child_process').execSync; -const BbPromise = require('bluebird'); const fse = require('fs-extra'); const testUtils = require('../utils/index'); const serverlessExec = path.join(__dirname, '..', '..', 'bin', 'serverless'); describe('simple packaging', () => { - let cwd + let cwd; beforeEach(() => { cwd = testUtils.getTmpDirPath(); fse.mkdirsSync(cwd); - }) + }); it('packages the default aws template correctly', () => { const templateName = 'aws-nodejs'; @@ -22,98 +21,101 @@ describe('simple packaging', () => { .then(zipfiles => { expect(zipfiles).toEqual(['handler.js']); }); - }) + }); it('packages the default aws template with an npm dep correctly', () => { const templateName = 'aws-nodejs'; execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); - execSync(`npm init --yes`, { cwd }); - execSync(`npm i lodash`, { cwd }); + execSync('npm init --yes', { cwd }); + execSync('npm i lodash', { cwd }); execSync(`${serverlessExec} package`, { cwd }); return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) .then(zipfiles => { - const nodeModules = new Set(zipfiles.filter(f => f.startsWith('node_modules')).map(f => f.split(path.sep)[1])); + const nodeModules = new Set( + zipfiles.filter(f => f.startsWith('node_modules')).map(f => f.split(path.sep)[1])); const nonNodeModulesFiles = zipfiles.filter(f => !f.startsWith('node_modules')); expect(nodeModules).toEqual(new Set(['lodash'])); expect(nonNodeModulesFiles).toEqual(['handler.js', 'package-lock.json', 'package.json']); }); - }) + }); it('doesn\'t package a dev dependency', () => { const templateName = 'aws-nodejs'; execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); - execSync(`npm init --yes`, { cwd }); - execSync(`npm i --save-dev lodash`, { cwd }); + execSync('npm init --yes', { cwd }); + execSync('npm i --save-dev lodash', { cwd }); execSync(`${serverlessExec} package`, { cwd }); return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) .then(zipfiles => { - const nodeModules = new Set(zipfiles.filter(f => f.startsWith('node_modules')).map(f => f.split(path.sep)[1])); + const nodeModules = new Set( + zipfiles.filter(f => f.startsWith('node_modules')).map(f => f.split(path.sep)[1])); const nonNodeModulesFiles = zipfiles.filter(f => !f.startsWith('node_modules')); expect(nodeModules).toEqual(new Set([])); expect(nonNodeModulesFiles).toEqual(['handler.js', 'package-lock.json', 'package.json']); }); - }) + }); it('ignores package json files per ignore directive', () => { const templateName = 'aws-nodejs'; execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); - execSync(`npm init --yes`, { cwd }); - execSync(`echo 'package: {exclude: ["package*.json"]}' >> serverless.yml`, { cwd }); - execSync(`npm i lodash`, { cwd }); + execSync('npm init --yes', { cwd }); + execSync('echo \'package: {exclude: ["package*.json"]}\' >> serverless.yml', { cwd }); + execSync('npm i lodash', { cwd }); execSync(`${serverlessExec} package`, { cwd }); return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) .then(zipfiles => { - const nodeModules = new Set(zipfiles.filter(f => f.startsWith('node_modules')).map(f => f.split(path.sep)[1])); + const nodeModules = new Set(i + zipfiles.filter(f => f.startsWith('node_modules')).map(f => f.split(path.sep)[1])); const nonNodeModulesFiles = zipfiles.filter(f => !f.startsWith('node_modules')); expect(nodeModules).toEqual(new Set(['lodash'])); expect(nonNodeModulesFiles).toEqual(['handler.js']); }); - }) -}) + }); +}); describe('cloudformation packaging', () => { - let cwd + let cwd; beforeEach(() => { cwd = testUtils.getTmpDirPath(); fse.mkdirsSync(cwd); - }) + }); it('creates the correct default function resource', () => { const templateName = 'aws-nodejs'; execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); execSync(`${serverlessExec} package`, { cwd }); const cfnTemplate = JSON.parse(fs.readFileSync(path.join( - cwd, '.serverless/cloudformation-template-update-stack.json'))) - expect(cfnTemplate.Resources.HelloLambdaFunction.Properties.Code.S3Key).toMatch(/serverless\/aws-nodejs\/dev\/[^]*\/aws-nodejs.zip/) - delete cfnTemplate.Resources.HelloLambdaFunction.Properties.Code.S3Key; - expect(cfnTemplate.Resources.HelloLambdaFunction).toEqual({ - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Ref": "ServerlessDeploymentBucket" - } + cwd, '.serverless/cloudformation-template-update-stack.json'))); + expect(cfnTemplate.Resources.HelloLambdaFunction.Properties.Code.S3Key).toMatch(/serverless\/aws-nodejs\/dev\/[^]*\/aws-nodejs.zip/); + delete cfnTemplate.Resources.HelloLambdaFunction.Properties.Code.S3Key; + expect(cfnTemplate.Resources.HelloLambdaFunction).toEqual({ + Type: 'AWS::Lambda::Function', + Properties: { + Code: { + S3Bucket: { + Ref: 'ServerlessDeploymentBucket', }, - "FunctionName": "aws-nodejs-dev-hello", - "Handler": "handler.hello", - "MemorySize": 1024, - "Role": { - "Fn::GetAtt": [ - "IamRoleLambdaExecution", - "Arn" - ] - }, - "Runtime": "nodejs8.10", - "Timeout": 6 }, - "DependsOn": [ - "HelloLogGroup", - "IamRoleLambdaExecution" - ] - }) + FunctionName: 'aws-nodejs-dev-hello', + Handler: 'handler.hello', + MemorySize: 1024, + Role: { + 'Fn::GetAtt': [ + 'IamRoleLambdaExecution', + 'Arn', + ], + }, + Runtime: 'nodejs8.10', + Timeout: 6, + }, + DependsOn: [ + 'HelloLogGroup', + 'IamRoleLambdaExecution', + ], + }); return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) .then(zipfiles => { expect(zipfiles).toEqual(['handler.js']); }); - }) -}) + }); +}); From fadade6014276a0f43c91ad44e3000f3f50a5f46 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Mon, 13 May 2019 16:08:23 -0400 Subject: [PATCH 03/23] doh --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a7fd54d22..7cc93cba4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ sudo: false install: - travis_retry npm install script: -- if [[ -z "$INTEGRATION_TEST" && -z "$DISABLE_TESTS" ]]; then npm test && npm local-integration-test; fi +- if [[ -z "$INTEGRATION_TEST" && -z "$DISABLE_TESTS" ]]; then npm test && npm run local-integration-test; fi - if [[ ! -z "$DISABLE_TESTS" && ! -z "$LINTING" && -z "$INTEGRATION_TEST" ]]; then npm run lint; fi - if [[ ! -z "$INTEGRATION_TEST" && ! -z ${AWS_ACCESS_KEY_ID+x} && "$INTEGRATION_TEST_SUITE" From 317f1eabe29f106e1401f37658a5abf9ad3a514a Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Mon, 13 May 2019 16:19:41 -0400 Subject: [PATCH 04/23] super doh --- tests/local-suite/packaging.tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/local-suite/packaging.tests.js b/tests/local-suite/packaging.tests.js index f2fd0fd39..d6b2b9867 100644 --- a/tests/local-suite/packaging.tests.js +++ b/tests/local-suite/packaging.tests.js @@ -64,7 +64,7 @@ describe('simple packaging', () => { execSync(`${serverlessExec} package`, { cwd }); return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) .then(zipfiles => { - const nodeModules = new Set(i + const nodeModules = new Set( zipfiles.filter(f => f.startsWith('node_modules')).map(f => f.split(path.sep)[1])); const nonNodeModulesFiles = zipfiles.filter(f => !f.startsWith('node_modules')); expect(nodeModules).toEqual(new Set(['lodash'])); From aa6b3934a7d5481f4f40cda970f1c98709864c8a Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Tue, 14 May 2019 10:26:09 -0400 Subject: [PATCH 05/23] update npm before starting travis stuff --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 7cc93cba4..421840c05 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,7 @@ sudo: false install: - travis_retry npm install script: +- npm i -g npm - if [[ -z "$INTEGRATION_TEST" && -z "$DISABLE_TESTS" ]]; then npm test && npm run local-integration-test; fi - if [[ ! -z "$DISABLE_TESTS" && ! -z "$LINTING" && -z "$INTEGRATION_TEST" ]]; then npm run lint; fi From 2344bbc70e138c3449f719f870f2055809fd9d21 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Tue, 14 May 2019 10:58:30 -0400 Subject: [PATCH 06/23] droping ancient nodes that cant run new npm --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 421840c05..81e59e9de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,6 @@ matrix: - secure: ruPmxtjLY9jX/TQQe1d8vxwL0KsjsTzJK/EL6rZM954JJc+3c5gshxB1Ca9+WRwIGdMjCZgKo4dQcn2DrAap7KoDz+GRCi40kc5AOr2ZLmjxJeCJls+sQ713QJ01GgIA1X2zmz/bDSw5lan8ODR3eYI0fIn37ZV4yxNJ5PObBLCMQW6nnOdMXxcLLi2iJRqu3k0gb85wsUNOB0AF2cBrbxoYmGsrGjGuPjIXPeEdnVJ0jzBY+jDrBraIHEBN9tecIyG77ZgEhlPopqTrj39dEPMwAow+derEVWugPRF3Wps6z+Yx0qtxETptWuOgn0V9GpfZF9vJlHifQUuuJEGtttVCYjZCUOIoIRwWnX+/SygjlgLJ9PpVa6XyZfnqygJXnv7wouGGkiyZEDbayu65qP3Ls/Dj+N2nEtamOPf3dGBeaX8KKF61h80bH7o9JL/t6yxyvm+yDRTkYd9SNk3U7dFXoBcCcjMNNUkKBKtY9G3EZlE0ZV0D7jD33Na4yX8mKBHkYLKXCAn+rh6DIwLNkV8IOtAYD77qan6v4qH9fpPMX4UkLu9SRM1r5RfsZU0gX7sCP9OKFKkAx5BWUqjg+D6Xa0EACtO8bPDHA548hWU2vYx7ghuVJfVNOUlAl97OXclx2SZwXJ46rHaHgrH2I3gi3qyHMib3iUV7SLdRQnY= - secure: p9ka7mRzo/ecjnDh/dz19g0iVfQdvsGRAtg/4ONeiq75I2+oqHzu+VxUBA1Z2IQbpCEAMo21CarR3fg2I6MFUeazL0nEpqr1PoOAI8nPFeQlg/h+jLXsrPAkDcu2/b8ij7J5MXeLdZXUVqiPcGkr68x/tCMk/rwxftljQhvXPQfc7Lxm/m61ELnC7rLJulhxWZLNIq1hwQ9nh0GMKb4hm0KmPn8ksccVL+wyDikkgXCuvIujhTBjhNivAe4mG8mqnNsW1Ugh++SUe1ld27TtbH7wQj02SSG4Bxfwc3Gz0GFdAL1GyOkWI2WvrqP4a0KYTRUo+pUr9E+HZ1SNlxU5t6QWtmDiy5MKkxzgeTXmkKiJ98vMlF0ja5bpp46NjYarzDafqE8FozHzLtr+uAtqr6gRAgU1rWaG9BE3gKeW/f4B/2MfPI26b7SxuU1MwGVy0I76hb0Ujbgb3X8G4TYTGb6Nhoewc+RZExPwVhfrN8cJjo45masndv5tQAZMSRX/JUFjs4h/QMXNsn0A53GXgf6eIzUu15m+W8TJYFiKQeq9nMejzEE4sWMO3BFnkxueBGVCEurOc1GgdEnKxeqlp+psxHcJRlNCxC1HkUVOzfpkCr/Jy42vM8jQomAMv41Z9zWjOagVphWT25xNeSILfRt4yPku5wfW4CAxp+fl4KQ= include: - - node_js: '4.4' - env: SLS_IGNORE_WARNING=* - - node_js: '5.11' - env: SLS_IGNORE_WARNING=* - node_js: '6.2' env: SLS_IGNORE_WARNING=* - node_js: '6.2' From 657510c81aea8fb69264589bc5bbfde0e79d8e1e Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Tue, 14 May 2019 11:23:38 -0400 Subject: [PATCH 07/23] lint --- tests/local-suite/packaging.tests.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/local-suite/packaging.tests.js b/tests/local-suite/packaging.tests.js index d6b2b9867..7c947a313 100644 --- a/tests/local-suite/packaging.tests.js +++ b/tests/local-suite/packaging.tests.js @@ -86,7 +86,8 @@ describe('cloudformation packaging', () => { execSync(`${serverlessExec} package`, { cwd }); const cfnTemplate = JSON.parse(fs.readFileSync(path.join( cwd, '.serverless/cloudformation-template-update-stack.json'))); - expect(cfnTemplate.Resources.HelloLambdaFunction.Properties.Code.S3Key).toMatch(/serverless\/aws-nodejs\/dev\/[^]*\/aws-nodejs.zip/); + expect(cfnTemplate.Resources.HelloLambdaFunction.Properties.Code.S3Key) + .toMatch(/serverless\/aws-nodejs\/dev\/[^]*\/aws-nodejs.zip/); delete cfnTemplate.Resources.HelloLambdaFunction.Properties.Code.S3Key; expect(cfnTemplate.Resources.HelloLambdaFunction).toEqual({ Type: 'AWS::Lambda::Function', From bad4b3ccb6fac8d9949d49a40312cfc744ecb56e Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Tue, 21 May 2019 11:16:06 -0400 Subject: [PATCH 08/23] rename test suite --- .travis.yml | 2 +- package.json | 2 +- tests/{local-suite => packaging-suite}/packaging.tests.js | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename tests/{local-suite => packaging-suite}/packaging.tests.js (100%) diff --git a/.travis.yml b/.travis.yml index 81e59e9de..876b97c72 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ install: - travis_retry npm install script: - npm i -g npm -- if [[ -z "$INTEGRATION_TEST" && -z "$DISABLE_TESTS" ]]; then npm test && npm run local-integration-test; fi +- if [[ -z "$INTEGRATION_TEST" && -z "$DISABLE_TESTS" ]]; then npm test && npm run packaging-integration-test; fi - if [[ ! -z "$DISABLE_TESTS" && ! -z "$LINTING" && -z "$INTEGRATION_TEST" ]]; then npm run lint; fi - if [[ ! -z "$INTEGRATION_TEST" && ! -z ${AWS_ACCESS_KEY_ID+x} && "$INTEGRATION_TEST_SUITE" diff --git a/package.json b/package.json index 147caab8e..d8f5c6765 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "lint": "eslint . --cache", "docs": "node scripts/generate-readme.js", "integration-test-cleanup": "node scripts/integration-test-cleanup.js", - "local-integration-test": "jest --maxWorkers=5 local-suite", + "packaging-integration-test": "jest --maxWorkers=5 packaging-suite", "simple-integration-test": "jest --maxWorkers=5 simple-suite", "complex-integration-test": "jest --maxWorkers=5 integration", "postinstall": "node ./scripts/postinstall.js" diff --git a/tests/local-suite/packaging.tests.js b/tests/packaging-suite/packaging.tests.js similarity index 100% rename from tests/local-suite/packaging.tests.js rename to tests/packaging-suite/packaging.tests.js From c6a974d1de8fcd03d49afda47673ffb40619016e Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Tue, 21 May 2019 11:18:15 -0400 Subject: [PATCH 09/23] update tests with strict and new copy --- tests/packaging-suite/packaging.tests.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/packaging-suite/packaging.tests.js b/tests/packaging-suite/packaging.tests.js index 7c947a313..b8ab81fb2 100644 --- a/tests/packaging-suite/packaging.tests.js +++ b/tests/packaging-suite/packaging.tests.js @@ -1,3 +1,5 @@ +'use strict'; + const fs = require('fs'); const path = require('path'); const execSync = require('child_process').execSync; @@ -6,14 +8,14 @@ const testUtils = require('../utils/index'); const serverlessExec = path.join(__dirname, '..', '..', 'bin', 'serverless'); -describe('simple packaging', () => { +describe('Integration test - Packaging', () => { let cwd; beforeEach(() => { cwd = testUtils.getTmpDirPath(); fse.mkdirsSync(cwd); }); - it('packages the default aws template correctly', () => { + it('packages the default aws template correctly in the zip', () => { const templateName = 'aws-nodejs'; execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); execSync(`${serverlessExec} package`, { cwd }); @@ -23,7 +25,7 @@ describe('simple packaging', () => { }); }); - it('packages the default aws template with an npm dep correctly', () => { + it('packages the default aws template with an npm dep correctly in the zip', () => { const templateName = 'aws-nodejs'; execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); execSync('npm init --yes', { cwd }); @@ -39,7 +41,7 @@ describe('simple packaging', () => { }); }); - it('doesn\'t package a dev dependency', () => { + it('doesn\'t package a dev dependency in the zip', () => { const templateName = 'aws-nodejs'; execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); execSync('npm init --yes', { cwd }); @@ -55,7 +57,7 @@ describe('simple packaging', () => { }); }); - it('ignores package json files per ignore directive', () => { + it('ignores package json files per ignore directive in the zip', () => { const templateName = 'aws-nodejs'; execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); execSync('npm init --yes', { cwd }); @@ -73,14 +75,14 @@ describe('simple packaging', () => { }); }); -describe('cloudformation packaging', () => { +describe('Integration test - Packaging', () => { let cwd; beforeEach(() => { cwd = testUtils.getTmpDirPath(); fse.mkdirsSync(cwd); }); - it('creates the correct default function resource', () => { + it('creates the correct default function resource in cfn template', () => { const templateName = 'aws-nodejs'; execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); execSync(`${serverlessExec} package`, { cwd }); From dc4e4ea569dc18c3a56a49f280a11d96a7db4b51 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Tue, 21 May 2019 11:22:59 -0400 Subject: [PATCH 10/23] why did i upgrade npm? --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 876b97c72..c1059938f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,6 @@ sudo: false install: - travis_retry npm install script: -- npm i -g npm - if [[ -z "$INTEGRATION_TEST" && -z "$DISABLE_TESTS" ]]; then npm test && npm run packaging-integration-test; fi - if [[ ! -z "$DISABLE_TESTS" && ! -z "$LINTING" && -z "$INTEGRATION_TEST" ]]; then npm run lint; fi From 34fc5718c16ef5b034c98a7bd73096ae991b701c Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Tue, 21 May 2019 11:36:04 -0400 Subject: [PATCH 11/23] expect node 10! --- tests/packaging-suite/packaging.tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/packaging-suite/packaging.tests.js b/tests/packaging-suite/packaging.tests.js index b8ab81fb2..d6fdf1631 100644 --- a/tests/packaging-suite/packaging.tests.js +++ b/tests/packaging-suite/packaging.tests.js @@ -108,7 +108,7 @@ describe('Integration test - Packaging', () => { 'Arn', ], }, - Runtime: 'nodejs8.10', + Runtime: 'nodejs10.x', Timeout: 6, }, DependsOn: [ From a8db8f4685ba57db69fd06e7dc9d8754c0e07060 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Tue, 21 May 2019 11:37:07 -0400 Subject: [PATCH 12/23] re-add npm upgrade and reason why --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index c1059938f..06d77fc41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,6 +39,8 @@ matrix: sudo: false install: - travis_retry npm install + # needed for consistency in output during packaging tests. old versions don't create a lock file +- travis_retry npm install -g npm script: - if [[ -z "$INTEGRATION_TEST" && -z "$DISABLE_TESTS" ]]; then npm test && npm run packaging-integration-test; fi - if [[ ! -z "$DISABLE_TESTS" && ! -z "$LINTING" && -z "$INTEGRATION_TEST" ]]; then From bd5a4ac52e4db5dd8bbf718967bfad72717e2ce7 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Wed, 22 May 2019 08:04:36 -0400 Subject: [PATCH 13/23] remove use of sls create in packaging tests --- tests/packaging-suite/handler.js | 14 ++++++++++++++ tests/packaging-suite/packaging.tests.js | 15 ++++++++++----- tests/packaging-suite/serverless.yml | 10 ++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 tests/packaging-suite/handler.js create mode 100644 tests/packaging-suite/serverless.yml diff --git a/tests/packaging-suite/handler.js b/tests/packaging-suite/handler.js new file mode 100644 index 000000000..8d524e278 --- /dev/null +++ b/tests/packaging-suite/handler.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports.hello = async (event) => { + return { + statusCode: 200, + body: JSON.stringify({ + message: 'Go Serverless v1.0! Your function executed successfully!', + input: event, + }, null, 2), + }; + + // Use this code if you don't use the http event with the LAMBDA-PROXY integration + // return { message: 'Go Serverless v1.0! Your function executed successfully!', event }; +}; diff --git a/tests/packaging-suite/packaging.tests.js b/tests/packaging-suite/packaging.tests.js index d6fdf1631..4d5e75801 100644 --- a/tests/packaging-suite/packaging.tests.js +++ b/tests/packaging-suite/packaging.tests.js @@ -17,7 +17,8 @@ describe('Integration test - Packaging', () => { it('packages the default aws template correctly in the zip', () => { const templateName = 'aws-nodejs'; - execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); + fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) + fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync(`${serverlessExec} package`, { cwd }); return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) .then(zipfiles => { @@ -27,7 +28,8 @@ describe('Integration test - Packaging', () => { it('packages the default aws template with an npm dep correctly in the zip', () => { const templateName = 'aws-nodejs'; - execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); + fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) + fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync('npm init --yes', { cwd }); execSync('npm i lodash', { cwd }); execSync(`${serverlessExec} package`, { cwd }); @@ -43,7 +45,8 @@ describe('Integration test - Packaging', () => { it('doesn\'t package a dev dependency in the zip', () => { const templateName = 'aws-nodejs'; - execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); + fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) + fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync('npm init --yes', { cwd }); execSync('npm i --save-dev lodash', { cwd }); execSync(`${serverlessExec} package`, { cwd }); @@ -59,7 +62,8 @@ describe('Integration test - Packaging', () => { it('ignores package json files per ignore directive in the zip', () => { const templateName = 'aws-nodejs'; - execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); + fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) + fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync('npm init --yes', { cwd }); execSync('echo \'package: {exclude: ["package*.json"]}\' >> serverless.yml', { cwd }); execSync('npm i lodash', { cwd }); @@ -84,7 +88,8 @@ describe('Integration test - Packaging', () => { it('creates the correct default function resource in cfn template', () => { const templateName = 'aws-nodejs'; - execSync(`${serverlessExec} create --template ${templateName}`, { cwd }); + fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) + fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync(`${serverlessExec} package`, { cwd }); const cfnTemplate = JSON.parse(fs.readFileSync(path.join( cwd, '.serverless/cloudformation-template-update-stack.json'))); diff --git a/tests/packaging-suite/serverless.yml b/tests/packaging-suite/serverless.yml new file mode 100644 index 000000000..700a3a5bd --- /dev/null +++ b/tests/packaging-suite/serverless.yml @@ -0,0 +1,10 @@ +service: aws-nodejs + +provider: + name: aws + runtime: nodejs10.x + + +functions: + hello: + handler: handler.hello From cabb1e3be61321dd9197dce23388639c55416347 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Wed, 22 May 2019 08:06:57 -0400 Subject: [PATCH 14/23] remove unused packaging name --- tests/packaging-suite/packaging.tests.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/packaging-suite/packaging.tests.js b/tests/packaging-suite/packaging.tests.js index 4d5e75801..0343934ef 100644 --- a/tests/packaging-suite/packaging.tests.js +++ b/tests/packaging-suite/packaging.tests.js @@ -16,7 +16,6 @@ describe('Integration test - Packaging', () => { }); it('packages the default aws template correctly in the zip', () => { - const templateName = 'aws-nodejs'; fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync(`${serverlessExec} package`, { cwd }); @@ -27,7 +26,6 @@ describe('Integration test - Packaging', () => { }); it('packages the default aws template with an npm dep correctly in the zip', () => { - const templateName = 'aws-nodejs'; fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync('npm init --yes', { cwd }); @@ -44,7 +42,6 @@ describe('Integration test - Packaging', () => { }); it('doesn\'t package a dev dependency in the zip', () => { - const templateName = 'aws-nodejs'; fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync('npm init --yes', { cwd }); @@ -87,7 +84,6 @@ describe('Integration test - Packaging', () => { }); it('creates the correct default function resource in cfn template', () => { - const templateName = 'aws-nodejs'; fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync(`${serverlessExec} package`, { cwd }); From 50c6fd35d89a3b521dc42174b0a542a8a8986de8 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Wed, 22 May 2019 08:19:35 -0400 Subject: [PATCH 15/23] a test covering artifact directive usage --- tests/packaging-suite/packaging.tests.js | 37 +++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/packaging-suite/packaging.tests.js b/tests/packaging-suite/packaging.tests.js index 0343934ef..13428ff30 100644 --- a/tests/packaging-suite/packaging.tests.js +++ b/tests/packaging-suite/packaging.tests.js @@ -58,7 +58,6 @@ describe('Integration test - Packaging', () => { }); it('ignores package json files per ignore directive in the zip', () => { - const templateName = 'aws-nodejs'; fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync('npm init --yes', { cwd }); @@ -82,6 +81,42 @@ describe('Integration test - Packaging', () => { cwd = testUtils.getTmpDirPath(); fse.mkdirsSync(cwd); }); + it('package artifact directive works', () => { + fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) + fs.copyFileSync(path.join(__dirname, 'artifact.zip'), path.join(cwd, 'artifact.zip')) + execSync('echo \'package: {artifact: artifact.zip}\' >> serverless.yml', { cwd }); + execSync(`${serverlessExec} package`, { cwd }); + const cfnTemplate = JSON.parse(fs.readFileSync(path.join( + cwd, '.serverless/cloudformation-template-update-stack.json'))); + expect(cfnTemplate.Resources.HelloLambdaFunction.Properties.Code.S3Key) + .toMatch(/serverless\/aws-nodejs\/dev\/[^]*\/artifact.zip/); + delete cfnTemplate.Resources.HelloLambdaFunction.Properties.Code.S3Key; + expect(cfnTemplate.Resources.HelloLambdaFunction).toEqual({ + Type: 'AWS::Lambda::Function', + Properties: { + Code: { + S3Bucket: { + Ref: 'ServerlessDeploymentBucket', + }, + }, + FunctionName: 'aws-nodejs-dev-hello', + Handler: 'handler.hello', + MemorySize: 1024, + Role: { + 'Fn::GetAtt': [ + 'IamRoleLambdaExecution', + 'Arn', + ], + }, + Runtime: 'nodejs10.x', + Timeout: 6, + }, + DependsOn: [ + 'HelloLogGroup', + 'IamRoleLambdaExecution', + ], + }); + }); it('creates the correct default function resource in cfn template', () => { fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) From bc9dc0895b2970ab008f05ccecb7ccd3590893e9 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Wed, 22 May 2019 08:36:37 -0400 Subject: [PATCH 16/23] package individually test --- tests/packaging-suite/handler2.js | 14 +++++++ tests/packaging-suite/individually.yml | 24 ++++++++++++ tests/packaging-suite/packaging.tests.js | 50 ++++++++++++++++++++---- 3 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 tests/packaging-suite/handler2.js create mode 100644 tests/packaging-suite/individually.yml diff --git a/tests/packaging-suite/handler2.js b/tests/packaging-suite/handler2.js new file mode 100644 index 000000000..8d524e278 --- /dev/null +++ b/tests/packaging-suite/handler2.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports.hello = async (event) => { + return { + statusCode: 200, + body: JSON.stringify({ + message: 'Go Serverless v1.0! Your function executed successfully!', + input: event, + }, null, 2), + }; + + // Use this code if you don't use the http event with the LAMBDA-PROXY integration + // return { message: 'Go Serverless v1.0! Your function executed successfully!', event }; +}; diff --git a/tests/packaging-suite/individually.yml b/tests/packaging-suite/individually.yml new file mode 100644 index 000000000..df2d79d23 --- /dev/null +++ b/tests/packaging-suite/individually.yml @@ -0,0 +1,24 @@ +service: aws-nodejs + +provider: + name: aws + runtime: nodejs10.x + +package: + individually: true + +functions: + hello: + handler: handler.hello + package: + include: + - handler.js + exclude: + - handler2.js + hello2: + handler: handler2.hello + package: + include: + - handler2.js + exclude: + - handler.js diff --git a/tests/packaging-suite/packaging.tests.js b/tests/packaging-suite/packaging.tests.js index 13428ff30..e321533e5 100644 --- a/tests/packaging-suite/packaging.tests.js +++ b/tests/packaging-suite/packaging.tests.js @@ -73,14 +73,7 @@ describe('Integration test - Packaging', () => { expect(nonNodeModulesFiles).toEqual(['handler.js']); }); }); -}); -describe('Integration test - Packaging', () => { - let cwd; - beforeEach(() => { - cwd = testUtils.getTmpDirPath(); - fse.mkdirsSync(cwd); - }); it('package artifact directive works', () => { fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) fs.copyFileSync(path.join(__dirname, 'artifact.zip'), path.join(cwd, 'artifact.zip')) @@ -157,4 +150,47 @@ describe('Integration test - Packaging', () => { expect(zipfiles).toEqual(['handler.js']); }); }); + + it('handles package individually with include/excludes correctly', () => { + fs.copyFileSync(path.join(__dirname, 'individually.yml'), path.join(cwd, 'serverless.yml')) + fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) + fs.copyFileSync(path.join(__dirname, 'handler2.js'), path.join(cwd, 'handler2.js')) + execSync(`${serverlessExec} package`, { cwd }); + const cfnTemplate = JSON.parse(fs.readFileSync(path.join( + cwd, '.serverless/cloudformation-template-update-stack.json'))); + expect(cfnTemplate.Resources.HelloLambdaFunction.Properties.Code.S3Key) + .toMatch(/serverless\/aws-nodejs\/dev\/[^]*\/hello.zip/); + expect(cfnTemplate.Resources.Hello2LambdaFunction.Properties.Code.S3Key) + .toMatch(/serverless\/aws-nodejs\/dev\/[^]*\/hello2.zip/); + delete cfnTemplate.Resources.HelloLambdaFunction.Properties.Code.S3Key; + expect(cfnTemplate.Resources.HelloLambdaFunction).toEqual({ + Type: 'AWS::Lambda::Function', + Properties: { + Code: { + S3Bucket: { + Ref: 'ServerlessDeploymentBucket', + }, + }, + FunctionName: 'aws-nodejs-dev-hello', + Handler: 'handler.hello', + MemorySize: 1024, + Role: { + 'Fn::GetAtt': [ + 'IamRoleLambdaExecution', + 'Arn', + ], + }, + Runtime: 'nodejs10.x', + Timeout: 6, + }, + DependsOn: [ + 'HelloLogGroup', + 'IamRoleLambdaExecution', + ], + }); + return testUtils.listZipFiles(path.join(cwd, '.serverless/hello.zip')) + .then(zipfiles => expect(zipfiles).toEqual(['handler.js'])) + .then(() => testUtils.listZipFiles(path.join(cwd, '.serverless/hello2.zip'))) + .then(zipfiles => expect(zipfiles).toEqual(['handler2.js'])); + }); }); From 60c422e2768d6be72293c45d1c45a70187619b48 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Wed, 22 May 2019 08:48:12 -0400 Subject: [PATCH 17/23] checkin artifact.zip for packaging tests --- tests/packaging-suite/artifact.zip | Bin 0 -> 1696 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/packaging-suite/artifact.zip diff --git a/tests/packaging-suite/artifact.zip b/tests/packaging-suite/artifact.zip new file mode 100644 index 0000000000000000000000000000000000000000..325409f5c64b05b1928d6d1b1674a40285573dd2 GIT binary patch literal 1696 zcmZ{lYg7_u7{^HgNz=UME$?abN}7hIX01>Xr>MhQ*u2X{O_NLnomk##q?Y%XWWx-D zTr@-kc>*4fVf&w0=Lyyra6`{DoL_eUXRf$9K=v;Y7j z>G?+r(l-1o5f>94NwmQyb5Nm3-U0RW$$Cff8*t+tGTW2W-Khbp%op?I$XdTy&=Td-~~m{aT5i&WD=G4~a3$BWqm3BlP`?%$WSR3ZBg{IgD>%qQF*s~c-vSl$)4s7f=wG3h? zIMrrPLk>NdN>emEuCR>$>6qKl0kqEf)K*9fDX{^_YRr2&tp95dvU)cp8W8~4P%*J; zH)QjZw4YVtXZYGX4db-bMRxIB<*#`3wT6=rHR z;tR8sWpxG(#91VKQpKtpj@3<(qFSx$$&)mU19q|WXQNiZg zE(a6Td8~LSjYBKQHfU=X7dquO8)3xr?|6qXfxXk%b1C@yH4-@tN%!%^d*9}DX(x0I z;?F292(LH~lt+?&u>~BM3C*!DKCD5z*31PY1`C$&Uo(jr8SK3pJDnsrC}Q%#Q@%&~ zKzD)J7G;K)=@e!vG2g-=n>u?OaV&f({@b1lRB>#)&7^TF5X7^@ReXDk&7`a7bTnby(4GgnC}?mN(B3Y<_OU z++^Tu$}uMddKB(D-@dd{c%r(fq2o}#oFja;<}!kL2g#pI&B?$zx))8CX*tOon5+a9#U+&YrUO@qs9Y0YeL_{-iR>iAuomgDa+hR~W+n z-*F|@4En?qnXwmHcXR4IyLzvW1zswEEsFwqX!yG61N=SrH@%eF09bTh@w1O=c(hGx>bW!u&7ByxpBn>c+ z{S%r=VQrvhAE|zLH1{5h7J!uF+8N$vReAl)YU7~#?8Bb(&#|Y}dcC)F!#>Q2?Anex z?*%z_7fZ^Upl;B6eL@Ql9GB8kM9@p943%@!^%84eB%ZV8-m(87+qt)@bac}-3wS+d zqp4ee&a?j3j2e!-`8L;}<*VK3l*jC_KyR~pLBc6rLG-xllmL7tRUD8io=^b0k{^Pj zzG&p+9^e0pGW43~7veiE(y2{eS=T-#vDX`>TjalDRE{i$L=->LSn-xDgI;q-)=L6R zxi*c3n~Fr*U^|ZD3WX{yeY4HBOI7fCIuHPWYHYJ@hm5uCKaub`_qHS9lMDe&>UQ^8 kK>U00^G~<2_(|J~4pM~v7m_F>2)sQbBQ28jR{8t&7YaP-_W%F@ literal 0 HcmV?d00001 From c6380b0f21ae1bc4f26d38b31834cca9adcd5d07 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Wed, 22 May 2019 09:09:34 -0400 Subject: [PATCH 18/23] huh. copyFileSync is newisH/ --- tests/packaging-suite/packaging.tests.js | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/packaging-suite/packaging.tests.js b/tests/packaging-suite/packaging.tests.js index e321533e5..58dbb8312 100644 --- a/tests/packaging-suite/packaging.tests.js +++ b/tests/packaging-suite/packaging.tests.js @@ -16,8 +16,8 @@ describe('Integration test - Packaging', () => { }); it('packages the default aws template correctly in the zip', () => { - fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) - fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) + fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) + fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync(`${serverlessExec} package`, { cwd }); return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) .then(zipfiles => { @@ -26,8 +26,8 @@ describe('Integration test - Packaging', () => { }); it('packages the default aws template with an npm dep correctly in the zip', () => { - fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) - fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) + fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) + fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync('npm init --yes', { cwd }); execSync('npm i lodash', { cwd }); execSync(`${serverlessExec} package`, { cwd }); @@ -42,8 +42,8 @@ describe('Integration test - Packaging', () => { }); it('doesn\'t package a dev dependency in the zip', () => { - fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) - fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) + fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) + fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync('npm init --yes', { cwd }); execSync('npm i --save-dev lodash', { cwd }); execSync(`${serverlessExec} package`, { cwd }); @@ -58,8 +58,8 @@ describe('Integration test - Packaging', () => { }); it('ignores package json files per ignore directive in the zip', () => { - fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) - fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) + fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) + fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync('npm init --yes', { cwd }); execSync('echo \'package: {exclude: ["package*.json"]}\' >> serverless.yml', { cwd }); execSync('npm i lodash', { cwd }); @@ -75,8 +75,8 @@ describe('Integration test - Packaging', () => { }); it('package artifact directive works', () => { - fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) - fs.copyFileSync(path.join(__dirname, 'artifact.zip'), path.join(cwd, 'artifact.zip')) + fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) + fse.copyFileSync(path.join(__dirname, 'artifact.zip'), path.join(cwd, 'artifact.zip')) execSync('echo \'package: {artifact: artifact.zip}\' >> serverless.yml', { cwd }); execSync(`${serverlessExec} package`, { cwd }); const cfnTemplate = JSON.parse(fs.readFileSync(path.join( @@ -112,8 +112,8 @@ describe('Integration test - Packaging', () => { }); it('creates the correct default function resource in cfn template', () => { - fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) - fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) + fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) + fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) execSync(`${serverlessExec} package`, { cwd }); const cfnTemplate = JSON.parse(fs.readFileSync(path.join( cwd, '.serverless/cloudformation-template-update-stack.json'))); @@ -152,9 +152,9 @@ describe('Integration test - Packaging', () => { }); it('handles package individually with include/excludes correctly', () => { - fs.copyFileSync(path.join(__dirname, 'individually.yml'), path.join(cwd, 'serverless.yml')) - fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) - fs.copyFileSync(path.join(__dirname, 'handler2.js'), path.join(cwd, 'handler2.js')) + fse.copyFileSync(path.join(__dirname, 'individually.yml'), path.join(cwd, 'serverless.yml')) + fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) + fse.copyFileSync(path.join(__dirname, 'handler2.js'), path.join(cwd, 'handler2.js')) execSync(`${serverlessExec} package`, { cwd }); const cfnTemplate = JSON.parse(fs.readFileSync(path.join( cwd, '.serverless/cloudformation-template-update-stack.json'))); From d135b225b9bb1beeb05a1eaea7a9e43baf771167 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Wed, 22 May 2019 09:38:31 -0400 Subject: [PATCH 19/23] lint and remove identical file --- tests/packaging-suite/handler.js | 2 +- tests/packaging-suite/handler2.js | 14 ----------- tests/packaging-suite/packaging.tests.js | 30 ++++++++++++------------ 3 files changed, 16 insertions(+), 30 deletions(-) delete mode 100644 tests/packaging-suite/handler2.js diff --git a/tests/packaging-suite/handler.js b/tests/packaging-suite/handler.js index 8d524e278..4e3448672 100644 --- a/tests/packaging-suite/handler.js +++ b/tests/packaging-suite/handler.js @@ -1,6 +1,6 @@ 'use strict'; -module.exports.hello = async (event) => { +module.exports.hello = function (event) { return { statusCode: 200, body: JSON.stringify({ diff --git a/tests/packaging-suite/handler2.js b/tests/packaging-suite/handler2.js deleted file mode 100644 index 8d524e278..000000000 --- a/tests/packaging-suite/handler2.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports.hello = async (event) => { - return { - statusCode: 200, - body: JSON.stringify({ - message: 'Go Serverless v1.0! Your function executed successfully!', - input: event, - }, null, 2), - }; - - // Use this code if you don't use the http event with the LAMBDA-PROXY integration - // return { message: 'Go Serverless v1.0! Your function executed successfully!', event }; -}; diff --git a/tests/packaging-suite/packaging.tests.js b/tests/packaging-suite/packaging.tests.js index 58dbb8312..e849febdb 100644 --- a/tests/packaging-suite/packaging.tests.js +++ b/tests/packaging-suite/packaging.tests.js @@ -16,8 +16,8 @@ describe('Integration test - Packaging', () => { }); it('packages the default aws template correctly in the zip', () => { - fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) - fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) + fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); + fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); execSync(`${serverlessExec} package`, { cwd }); return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) .then(zipfiles => { @@ -26,8 +26,8 @@ describe('Integration test - Packaging', () => { }); it('packages the default aws template with an npm dep correctly in the zip', () => { - fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) - fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) + fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); + fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); execSync('npm init --yes', { cwd }); execSync('npm i lodash', { cwd }); execSync(`${serverlessExec} package`, { cwd }); @@ -42,8 +42,8 @@ describe('Integration test - Packaging', () => { }); it('doesn\'t package a dev dependency in the zip', () => { - fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) - fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) + fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); + fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); execSync('npm init --yes', { cwd }); execSync('npm i --save-dev lodash', { cwd }); execSync(`${serverlessExec} package`, { cwd }); @@ -58,8 +58,8 @@ describe('Integration test - Packaging', () => { }); it('ignores package json files per ignore directive in the zip', () => { - fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) - fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) + fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); + fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); execSync('npm init --yes', { cwd }); execSync('echo \'package: {exclude: ["package*.json"]}\' >> serverless.yml', { cwd }); execSync('npm i lodash', { cwd }); @@ -75,8 +75,8 @@ describe('Integration test - Packaging', () => { }); it('package artifact directive works', () => { - fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) - fse.copyFileSync(path.join(__dirname, 'artifact.zip'), path.join(cwd, 'artifact.zip')) + fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); + fse.copyFileSync(path.join(__dirname, 'artifact.zip'), path.join(cwd, 'artifact.zip')); execSync('echo \'package: {artifact: artifact.zip}\' >> serverless.yml', { cwd }); execSync(`${serverlessExec} package`, { cwd }); const cfnTemplate = JSON.parse(fs.readFileSync(path.join( @@ -112,8 +112,8 @@ describe('Integration test - Packaging', () => { }); it('creates the correct default function resource in cfn template', () => { - fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')) - fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) + fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); + fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); execSync(`${serverlessExec} package`, { cwd }); const cfnTemplate = JSON.parse(fs.readFileSync(path.join( cwd, '.serverless/cloudformation-template-update-stack.json'))); @@ -152,9 +152,9 @@ describe('Integration test - Packaging', () => { }); it('handles package individually with include/excludes correctly', () => { - fse.copyFileSync(path.join(__dirname, 'individually.yml'), path.join(cwd, 'serverless.yml')) - fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')) - fse.copyFileSync(path.join(__dirname, 'handler2.js'), path.join(cwd, 'handler2.js')) + fse.copyFileSync(path.join(__dirname, 'individually.yml'), path.join(cwd, 'serverless.yml')); + fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); + fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler2.js')); execSync(`${serverlessExec} package`, { cwd }); const cfnTemplate = JSON.parse(fs.readFileSync(path.join( cwd, '.serverless/cloudformation-template-update-stack.json'))); From 2d3427a324e051f586e4ec5a032e4975beef389d Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Fri, 24 May 2019 13:57:06 -0400 Subject: [PATCH 20/23] fse.copySync instead --- tests/packaging-suite/packaging.tests.js | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/packaging-suite/packaging.tests.js b/tests/packaging-suite/packaging.tests.js index e849febdb..93da7ee95 100644 --- a/tests/packaging-suite/packaging.tests.js +++ b/tests/packaging-suite/packaging.tests.js @@ -16,8 +16,8 @@ describe('Integration test - Packaging', () => { }); it('packages the default aws template correctly in the zip', () => { - fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); - fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); + fse.copySync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); + fse.copySync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); execSync(`${serverlessExec} package`, { cwd }); return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip')) .then(zipfiles => { @@ -26,8 +26,8 @@ describe('Integration test - Packaging', () => { }); it('packages the default aws template with an npm dep correctly in the zip', () => { - fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); - fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); + fse.copySync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); + fse.copySync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); execSync('npm init --yes', { cwd }); execSync('npm i lodash', { cwd }); execSync(`${serverlessExec} package`, { cwd }); @@ -42,8 +42,8 @@ describe('Integration test - Packaging', () => { }); it('doesn\'t package a dev dependency in the zip', () => { - fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); - fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); + fse.copySync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); + fse.copySync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); execSync('npm init --yes', { cwd }); execSync('npm i --save-dev lodash', { cwd }); execSync(`${serverlessExec} package`, { cwd }); @@ -58,8 +58,8 @@ describe('Integration test - Packaging', () => { }); it('ignores package json files per ignore directive in the zip', () => { - fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); - fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); + fse.copySync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); + fse.copySync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); execSync('npm init --yes', { cwd }); execSync('echo \'package: {exclude: ["package*.json"]}\' >> serverless.yml', { cwd }); execSync('npm i lodash', { cwd }); @@ -75,8 +75,8 @@ describe('Integration test - Packaging', () => { }); it('package artifact directive works', () => { - fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); - fse.copyFileSync(path.join(__dirname, 'artifact.zip'), path.join(cwd, 'artifact.zip')); + fse.copySync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); + fse.copySync(path.join(__dirname, 'artifact.zip'), path.join(cwd, 'artifact.zip')); execSync('echo \'package: {artifact: artifact.zip}\' >> serverless.yml', { cwd }); execSync(`${serverlessExec} package`, { cwd }); const cfnTemplate = JSON.parse(fs.readFileSync(path.join( @@ -112,8 +112,8 @@ describe('Integration test - Packaging', () => { }); it('creates the correct default function resource in cfn template', () => { - fse.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); - fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); + fse.copySync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml')); + fse.copySync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); execSync(`${serverlessExec} package`, { cwd }); const cfnTemplate = JSON.parse(fs.readFileSync(path.join( cwd, '.serverless/cloudformation-template-update-stack.json'))); @@ -152,9 +152,9 @@ describe('Integration test - Packaging', () => { }); it('handles package individually with include/excludes correctly', () => { - fse.copyFileSync(path.join(__dirname, 'individually.yml'), path.join(cwd, 'serverless.yml')); - fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); - fse.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler2.js')); + fse.copySync(path.join(__dirname, 'individually.yml'), path.join(cwd, 'serverless.yml')); + fse.copySync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js')); + fse.copySync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler2.js')); execSync(`${serverlessExec} package`, { cwd }); const cfnTemplate = JSON.parse(fs.readFileSync(path.join( cwd, '.serverless/cloudformation-template-update-stack.json'))); From 6135a1e14c9701aaed2a7c2871e1a117424d2fd2 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Tue, 28 May 2019 16:03:01 -0400 Subject: [PATCH 21/23] fix yarn install of SFE integration closes #6181 --- CHANGELOG.md | 7 +++++++ lib/classes/PluginManager.js | 3 +++ package-lock.json | 2 +- package.json | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 482b93f64..129e36e83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 1.44.1 (2019-05-28) +- [Fix enterprise plugin lookup in global yarn installs](https://github.com/serverless/serverless/pull/TBD) + +## Meta +- [Comparison since last release](https://github.com/serverless/serverless/compare/v1.44.0...v1.44.1) + + # 1.44.0 (2019-05-28) - [Built in integration of Serverless Enterprise](https://github.com/serverless/serverless/pull/6074) diff --git a/lib/classes/PluginManager.js b/lib/classes/PluginManager.js index 44cceaf55..daf7260e3 100644 --- a/lib/classes/PluginManager.js +++ b/lib/classes/PluginManager.js @@ -159,6 +159,9 @@ class PluginManager { if (config.getGlobalConfig().enterpriseDisabled) { return; } + // `yarn global add` support, deps of deps are installed as deps + module.paths.unshift(path.join(__dirname, '../../../../node_modules')); + // `npm -i g` support, deps of deps are installed inside projects module.paths.unshift(path.join(__dirname, '../../node_modules')); this.loadPlugins(['@serverless/enterprise-plugin']); const sfePkgJson = require('@serverless/enterprise-plugin/package.json'); diff --git a/package-lock.json b/package-lock.json index 52b59fde0..287ddc192 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "serverless", - "version": "1.44.0", + "version": "1.44.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3c17a4b3a..b128a6a4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serverless", - "version": "1.44.0", + "version": "1.44.1", "engines": { "node": ">=6.0" }, From 116d30a9fcbfb7f73cb0260655df63731815b57a Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Tue, 28 May 2019 16:13:10 -0400 Subject: [PATCH 22/23] add PR number for this pr --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 129e36e83..2f29cd3a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # 1.44.1 (2019-05-28) -- [Fix enterprise plugin lookup in global yarn installs](https://github.com/serverless/serverless/pull/TBD) +- [Fix enterprise plugin lookup in global yarn installs](https://github.com/serverless/serverless/pull/6183) ## Meta - [Comparison since last release](https://github.com/serverless/serverless/compare/v1.44.0...v1.44.1) From 0716d258860360226c14c0253e89fb23ead9957c Mon Sep 17 00:00:00 2001 From: Mariusz Nowak Date: Wed, 29 May 2019 12:46:23 +0200 Subject: [PATCH 23/23] Fix mocha configuration (ensure custom reporter) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b128a6a4a..48c093b88 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ }, "mocha": { "require": "sinon-bluebird", - "-R": "tests/mocha-reporter" + "R": "tests/mocha-reporter" }, "jest": { "testRegex": "(\\.|/)(tests)\\.js$",