diff --git a/Chapter08/stubbing-http-requests/github.js b/Chapter08/stubbing-http-requests/github.js index a04e7cd..01f2e7b 100644 --- a/Chapter08/stubbing-http-requests/github.js +++ b/Chapter08/stubbing-http-requests/github.js @@ -7,3 +7,4 @@ module.exports.getGitHubUser = (username) => { return json; }); }; + diff --git a/Chapter08/stubbing-http-requests/test/octokitUserData.js b/Chapter08/stubbing-http-requests/test/octokitUserData.js index 4ea59cf..8956841 100644 --- a/Chapter08/stubbing-http-requests/test/octokitUserData.js +++ b/Chapter08/stubbing-http-requests/test/octokitUserData.js @@ -32,3 +32,4 @@ module.exports = { created_at: "2013-01-30T18:13:42Z", updated_at: "2020-06-09T20:53:23Z", }; + diff --git a/Chapter08/stubbing-http-requests/test/test.js b/Chapter08/stubbing-http-requests/test/test.js index 5426105..b55baa4 100644 --- a/Chapter08/stubbing-http-requests/test/test.js +++ b/Chapter08/stubbing-http-requests/test/test.js @@ -9,7 +9,7 @@ test("Get GitHub user by username", async function (t) { sinon.stub(github, "getGitHubUser").returns(octokitUserData); - const githubUser = await github.getGitHubUser("bethgriggs"); + const githubUser = await github.getGitHubUser("octokit"); t.equal(githubUser.id, 3430433); t.equal(githubUser.login, "octokit"); diff --git a/Chapter08/testing-with-jest/coverage/clover.xml b/Chapter08/testing-with-jest/coverage/clover.xml index bee0518..11ee9e1 100644 --- a/Chapter08/testing-with-jest/coverage/clover.xml +++ b/Chapter08/testing-with-jest/coverage/clover.xml @@ -1,6 +1,6 @@ - - + + diff --git a/Chapter08/testing-with-jest/coverage/lcov-report/index.html b/Chapter08/testing-with-jest/coverage/lcov-report/index.html index 05e2882..039b1bd 100644 --- a/Chapter08/testing-with-jest/coverage/lcov-report/index.html +++ b/Chapter08/testing-with-jest/coverage/lcov-report/index.html @@ -95,7 +95,7 @@ diff --git a/Chapter08/testing-with-jest/coverage/lcov-report/uppercase.js.html b/Chapter08/testing-with-jest/coverage/lcov-report/uppercase.js.html index ca42907..05af787 100644 --- a/Chapter08/testing-with-jest/coverage/lcov-report/uppercase.js.html +++ b/Chapter08/testing-with-jest/coverage/lcov-report/uppercase.js.html @@ -60,12 +60,15 @@ 1 2 3 -41x +4 +51x 1x   +   
module.exports = (string) => {
   return string.toUpperCase();
 };
+ 
  
@@ -73,7 +76,7 @@ diff --git a/Chapter08/testing-with-jest/test/test.js b/Chapter08/testing-with-jest/test/test.js index d4ff76b..224dd81 100644 --- a/Chapter08/testing-with-jest/test/test.js +++ b/Chapter08/testing-with-jest/test/test.js @@ -1,10 +1,8 @@ -let uppercase = require("./../uppercase"); +const uppercase = require("./../uppercase"); describe("uppercase", () => { test("uppercase hello returns HELLO", () => { - uppercase = jest.fn(() => "HELLO"); - const result = uppercase("hello"); - expect(uppercase).toHaveBeenCalledWith("hello"); - expect(result).toBe("HELLO"); + expect(uppercase("hello")).toBe("HELLO"); }); + }); diff --git a/Chapter08/testing-with-jest/uppercase.js b/Chapter08/testing-with-jest/uppercase.js index 0da29fa..097abd2 100644 --- a/Chapter08/testing-with-jest/uppercase.js +++ b/Chapter08/testing-with-jest/uppercase.js @@ -1,3 +1,4 @@ module.exports = (string) => { return string.toUpperCase(); }; + diff --git a/Chapter08/testing-with-mocha/calculator.js b/Chapter08/testing-with-mocha/calculator.js index ea7d55d..dbdac8f 100644 --- a/Chapter08/testing-with-mocha/calculator.js +++ b/Chapter08/testing-with-mocha/calculator.js @@ -1,15 +1,16 @@ module.exports.add = (number1, number2) => { - return number1 + number2; + return number1 + number2; }; module.exports.subtract = (number1, number2) => { - return number1 - number2; + return number1 - number2; }; module.exports.multiply = (number1, number2) => { - return number1 * number2; + return number1 * number2; }; module.exports.divide = (number1, number2) => { - return number1 / number2; + return number1 / number2; }; + diff --git a/Chapter08/testing-with-mocha/package-lock.json b/Chapter08/testing-with-mocha/package-lock.json index 96b1b5b..c8c1d28 100644 --- a/Chapter08/testing-with-mocha/package-lock.json +++ b/Chapter08/testing-with-mocha/package-lock.json @@ -1,5 +1,5 @@ { - "name": "testing-with-mocha", + "name": "Chapter08", "version": "1.0.0", "lockfileVersion": 1, "requires": true, diff --git a/Chapter08/testing-with-mocha/package.json b/Chapter08/testing-with-mocha/package.json index ca111f6..45a950c 100644 --- a/Chapter08/testing-with-mocha/package.json +++ b/Chapter08/testing-with-mocha/package.json @@ -1,15 +1,14 @@ { - "name": "testing-with-mocha", + "name": "Chapter08", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { - "test": "./node_modules/mocha/bin/mocha" + "test": "mocha" }, "keywords": [], "author": "", "license": "ISC", - "dependencies": {}, "devDependencies": { "chai": "^4.2.0", "mocha": "^8.0.1" diff --git a/Chapter08/using-puppeteer/test/test.js b/Chapter08/using-puppeteer/test/test.js index dd7d5c7..9798325 100644 --- a/Chapter08/using-puppeteer/test/test.js +++ b/Chapter08/using-puppeteer/test/test.js @@ -5,8 +5,8 @@ async function runTest() { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto("https://example.com"); - const title = await page.$eval("h1", (el) => el.innerText); + console.log("Title value:", title); assert.equal(title, "Example Domain");