Skip to content

Commit

Permalink
using jest parallel for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamkrishnar committed Jan 8, 2024
1 parent 17b50a8 commit 3b1b3d2
Show file tree
Hide file tree
Showing 20 changed files with 433 additions and 799 deletions.
16 changes: 8 additions & 8 deletions dist/blog-post-workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -6303,7 +6303,7 @@ var require_lib2 = __commonJS({
}
});

// node_modules/rss-parser/lib/utils.js
// node_modules/rss-parser/lib/testUtils.js
var require_utils = __commonJS({
"node_modules/rss-parser/lib/utils.js"(exports2, module2) {
var utils = module2.exports = {};
Expand Down Expand Up @@ -6740,7 +6740,7 @@ var require_rss_parser = __commonJS({
}
});

// node_modules/@actions/core/lib/utils.js
// node_modules/@actions/core/lib/testUtils.js
var require_utils2 = __commonJS({
"node_modules/@actions/core/lib/utils.js"(exports2) {
"use strict";
Expand Down Expand Up @@ -8235,7 +8235,7 @@ var require_auth = __commonJS({
}
});

// node_modules/@actions/core/lib/oidc-utils.js
// node_modules/@actions/core/lib/oidc-testUtils.js
var require_oidc_utils = __commonJS({
"node_modules/@actions/core/lib/oidc-utils.js"(exports2) {
"use strict";
Expand Down Expand Up @@ -8298,10 +8298,10 @@ var require_oidc_utils = __commonJS({
return __awaiter(this, void 0, void 0, function* () {
const httpclient = _OidcClient.createHttpClient();
const res = yield httpclient.getJson(id_token_url).catch((error) => {
throw new Error(`Failed to get ID Token.
throw new Error(`Failed to get ID Token.
Error Code : ${error.statusCode}
Error Message: ${error.message}`);
});
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
Expand Down Expand Up @@ -8627,7 +8627,7 @@ var require_summary = __commonJS({
}
});

// node_modules/@actions/core/lib/path-utils.js
// node_modules/@actions/core/lib/path-testUtils.js
var require_path_utils = __commonJS({
"node_modules/@actions/core/lib/path-utils.js"(exports2) {
"use strict";
Expand Down Expand Up @@ -9697,7 +9697,7 @@ var require_library = __commonJS({
}
});

// src/utils.js
// src/testUtils.js
var require_utils3 = __commonJS({
"src/utils.js"(exports2, module2) {
var { spawn } = require("child_process");
Expand Down
2 changes: 1 addition & 1 deletion local-run.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const process = require('process');
const path = require('path');
const fs = require('fs');
const {DEFAULT_TEST_ENV} = require('./test/default-env');
const {DEFAULT_TEST_ENV} = require('./test/testUtils/default-env');
// language=markdown
const template = `# Readme test
Post list example:
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"scripts": {
"build": "esbuild ./src/blog-post-workflow.js --bundle --platform=node --outfile=dist/blog-post-workflow.js",
"lint": "jshint --exclude='node_modules/' *.js",
"start-server": "node test/test-server.js",
"start-server": "node test/testUtils/test-server.js",
"local-run-script": "node local-run.js",
"local-run": "start-server-and-test start-server http://localhost:8080 local-run-script",
"test-run": "mocha test/test.js",
"test-run": "mocha --parallel --jobs 100 test/**.js",
"test": "yarn run lint && start-server-and-test start-server http://localhost:8080 test-run",
"test-run-dist": "DIST=true mocha test/test.js",
"test-run-dist": "DIST=true mocha test/default.js",
"test-dist": "yarn run lint && start-server-and-test start-server http://localhost:8080 test-run-dist"
},
"repository": {
Expand Down Expand Up @@ -42,7 +42,7 @@
},
"devDependencies": {
"jshint": "^2.12.0",
"mocha": "^8.1.3",
"mocha": "^10.2.0",
"start-server-and-test": "^1.11.3"
}
}
12 changes: 12 additions & 0 deletions test/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const {DEFAULT_TEST_ENV} = require('./testUtils/default-env');
const {runAndCompareSnap} = require('./testUtils/testUtils');
describe('Generated readme with $counter template', function () {
it('should match the snapshot', async function () {
const envObj = {
...process.env,
...DEFAULT_TEST_ENV,
INPUT_TEMPLATE: '- $counter $title'
};
await runAndCompareSnap('Readme.counter.md', envObj);
});
});
12 changes: 12 additions & 0 deletions test/custom-template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const {DEFAULT_TEST_ENV} = require('./testUtils/default-env');
const {runAndCompareSnap} = require('./testUtils/testUtils');
describe('Custom template readme generated', function () {
it('should match the snapshot', async function () {
const envObj = {
...process.env,
...DEFAULT_TEST_ENV,
INPUT_TEMPLATE: '$newline[$title]($url): $date $description $newline'
};
await runAndCompareSnap('Readme.custom.md', envObj);
});
});
10 changes: 10 additions & 0 deletions test/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const {DEFAULT_TEST_ENV} = require('./testUtils/default-env');
const {runAndCompareSnap} = require('./testUtils/testUtils');
describe('Default template readme generated', function () {
it('should match the snapshot', async function () {
const envObj = {
...DEFAULT_TEST_ENV
};
await runAndCompareSnap('Readme.md', envObj);
});
});
12 changes: 12 additions & 0 deletions test/disable-sort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const {DEFAULT_TEST_ENV} = require('./testUtils/default-env');
const {runAndCompareSnap} = require('./testUtils/testUtils');
describe('Sorting disabled readme', function () {
it('should be equal to the saved snapshot', async function () {
const envObj = {
...process.env,
...DEFAULT_TEST_ENV,
INPUT_DISABLE_SORT: 'true'
};
await runAndCompareSnap('Readme.sort.md', envObj);
});
});
12 changes: 12 additions & 0 deletions test/emojikey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const {DEFAULT_TEST_ENV} = require('./testUtils/default-env');
const {runAndCompareSnap} = require('./testUtils/testUtils');
describe('Generated readme with $emojiKey template', function () {
it('should match the snapshot', async function () {
const envObj = {
...process.env,
...DEFAULT_TEST_ENV,
INPUT_TEMPLATE: '- $emojiKey(💯,🔥)'
};
await runAndCompareSnap('Readme.emojiKey.md', envObj);
});
});
29 changes: 29 additions & 0 deletions test/multiple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const {DEFAULT_TEST_ENV} = require('./testUtils/default-env');
const path = require('path');
const fs = require('fs');
const assert = require('assert');
const {TEST_SNAP_DIR, TEMPLATE, TEST_FILE} = require("./testUtils/testUtils");
describe('Multiple readme generated via readme_path', function () {
it('should match the snapshots', async function () {
const readme1 = path.join(TEST_SNAP_DIR, 'Readme.multi.1.md');
const readme2 = path.join(TEST_SNAP_DIR, 'Readme.multi.2.md');
const envObj = {
...DEFAULT_TEST_ENV,
INPUT_README_PATH: readme1 + ',' + readme2
};
process.env = {
...process.env,
...envObj
};
fs.writeFileSync(readme1, TEMPLATE);
fs.writeFileSync(readme2, TEMPLATE);
const workflow = await require(TEST_FILE);
await workflow.runWorkflow();
const snapshot1 = fs.readFileSync(readme1 + '.snap', 'utf-8');
const snapshot2 = fs.readFileSync(readme2 + '.snap', 'utf-8');
const newReadme1 = fs.readFileSync(readme1, 'utf-8');
const newReadme2 = fs.readFileSync(readme2, 'utf-8');
assert.strictEqual(snapshot1, newReadme1);
assert.strictEqual(snapshot2, newReadme2);
});
});
12 changes: 12 additions & 0 deletions test/random-emoji.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const {DEFAULT_TEST_ENV} = require('./testUtils/default-env');
const {runAndCompareSnap} = require('./testUtils/testUtils');
describe('Default template readme generated', function () {
it('Generated readme with $randomEmoji template should match the snapshot', async function () {
const envObj = {
...process.env,
...DEFAULT_TEST_ENV,
INPUT_TEMPLATE: '- $randomEmoji(💯,🔥,💫,🚀,🌮)'
};
await runAndCompareSnap('Readme.randomEmoji.md', envObj);
});
});
Loading

0 comments on commit 3b1b3d2

Please sign in to comment.