Brian Douglas
// test is checking if the value is equal to the expectedValue
test('test description', function() {
expect(value).toBe(expectedValue);
});
// jest example
it('two plus two is four', () => {
expect(2 + 2).toBe(4);
});
// mocha example
it('two plus two is four', () => {
value = 2 + 2
assertEquals(value, 4, "This is an additional message you can write");
});
it('users can add items to the shopping list simultaneously', async () => {
// create mock data using a local mockApi server:
mockApi.mockGetItems([{id: 12, name: 'bananas'}, {id: 13, name: 'dill'}]);
// more test setup (ceremony)
clickAddNewItemButton();
fillInItemName('carrots');
clickSaveNewItemButton();
expect(getItems()).toEqual(['bananas', 'dill', 'carrots']);
});
clickAddNewItemButton() {
const button = screen.find(`[data-qa="${'add-new-item'}"]`)
click(button);
}
fillInItemName(name) {
const input = screen.find(`[data-qa="${'new-item-name'}"]`)
setValue(input, name);
}
import {LocalStorageMock, data, match} from "./mocks";
// set up local storage mock usage in component
global.localStorage = new LocalStorageMock
localStorage.setItem("currentOpenSaucedUser", JSON.stringify({...data}));
module.exports = {
'Test input works' : function (browser) {
browser
.url('http://www.your-site.com')
.waitForElementVisible('body', 1000)
.setValue('input[type=text]', 'carrots')
.waitForElementVisible('button[name=btnG]', 1000)
.click('button[name=btnG]')
.pause(1000)
.assert.containsText('#main', 'carrots')
.end();
}
};
A headless browser is a web browser without a graphical user interface. Headless browsers provide automated control of a web page in an environment similar to popular web browsers, but are executed via a command-line interface or using network communication.
fizzBuzzCustom()[15] // returns 16
fizzBuzzCustom()[44] // returns "FizzBuzz" (45 is divisible by 3 and 5)
fizzBuzzCustom('Hey', 'There')[25] // returns 26
fizzBuzzCustom('Hey', 'There')[11] // returns "Hey" (12 is divisible by 3)
fizzBuzzCustom("What's ", "up?", 3, 7)[80] // returns "What's " (81 is divisible by 3)