From 7db948421e8b8b737ae841790807722225cd9548 Mon Sep 17 00:00:00 2001 From: gautamkrishnar Date: Fri, 7 Aug 2020 20:26:25 +0530 Subject: [PATCH] Added automated testing of dist --- .travis.yml | 5 +++++ package.json | 5 +++-- test.js | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0e1ffaa..0f2c471 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,3 +5,8 @@ node_js: - 12 cache: npm: true +jobs: + include: + - stage: Test generated dist + if: tag IS present + script: yarn run test-dist diff --git a/package.json b/package.json index d9aaeb0..819569e 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,12 @@ "main": "blog-post-workflow.js", "scripts": { "start": "node blog-post-workflow.js", - "start-test": "node test.js", "local-run": "start-server-and-test start-server http://localhost:8080 start-test", - "test-run": "npm run start-test && diff test/Readme.md test/Readme.md.snap", "start-server": "node test/test-server.js", + "test-run": "node test.js && diff test/Readme.md test/Readme.md.snap", "test": "npm run lint && start-server-and-test start-server http://localhost:8080 test-run", + "test-run-dist": "DIST=true node test.js && diff test/Readme.md test/Readme.md.snap", + "test-dist": "npm run lint && start-server-and-test start-server http://localhost:8080 test-run-dist", "lint": "jshint --exclude='node_modules/' *.js", "build": "parcel build --no-source-maps --target=node --bundle-node-modules blog-post-workflow.js" }, diff --git a/test.js b/test.js index 375a7df..1f0bad8 100644 --- a/test.js +++ b/test.js @@ -18,6 +18,8 @@ fs.writeFile(path.join(__dirname, 'test', 'Readme.md'), template, () => { process.env.INPUT_DISABLE_SORT = "false"; process.env.INPUT_TEMPLATE = "default"; process.env.TEST_MODE = "true"; - require('./blog-post-workflow'); + const testFile = process.env.DIST ? './dist/blog-post-workflow' :'./blog-post-workflow'; + console.log('Testing: ', testFile); + require(testFile); });