Skip to content

Instantly share code, notes, and snippets.

@alexmi256
Created October 26, 2020 21:43
Show Gist options
  • Save alexmi256/f72155e37af28eb7b97b8c0bbb9dff09 to your computer and use it in GitHub Desktop.
Save alexmi256/f72155e37af28eb7b97b8c0bbb9dff09 to your computer and use it in GitHub Desktop.
/* eslint-disable */
import { Selector } from 'testcafe';
const TIER2 = { tier2: 'true' };
const SMOKE = { type: 'smoke' };
const OWNERS = { owner: 'team' };
fixture.meta(OWNERS)`All Passing Fixture`;
[...Array(2).keys()].forEach(testNumber => {
test.meta(SMOKE).meta(TIER2).meta({
suite: 'big suite',
epic: 'big epic',
story: 'big story',
feature: 'big feature',
description: 'Checks something else',
})(`Passing Test ${testNumber}`, async () => {});
test.meta(SMOKE).meta(TIER2).meta({
severity: 'critical',
story: 'As user I want to be able to do...',
description: 'Checks something',
})(`Passing Test With ALL META ${testNumber}`, async () => {});
});
test.meta(SMOKE).meta(TIER2).page('https://getbootstrap.com/docs/4.1/components/alerts/')(
`Passing Test with 2 screenshots`,
async t => {
await t.takeScreenshot();
await t.takeElementScreenshot(Selector('.alert'));
}
);
fixture.meta(OWNERS)`All Skipped Fixture`;
[...Array(2).keys()].forEach(testNumber => {
test.skip.meta(SMOKE).meta(TIER2)(`Skipped Test ${testNumber}`, async () => {});
});
fixture.meta(OWNERS)`All Failed Fixture`;
test.meta(SMOKE).meta(TIER2)(`Failed Test 1 Incorrect Assert`, async t => {
await t.expect(1).eql(0);
});
test.meta(SMOKE).meta(TIER2)(`Failed Test 2`, async t => {
await t.expect(Selector('body').find('foo').hasAttribute('bar')).ok();
});
test.meta(SMOKE).meta(TIER2)(`Failed Test 3 No `, async t => {
const bar = {};
bar.toString2();
});
test.meta(SMOKE).meta(TIER2).meta({
suite: 'big suite',
epic: 'big epic',
story: 'big story',
feature: 'big feature',
})(`Failed Test 4 Error Thrown`, async t => {
throw new Error('Boo');
});
test.meta(SMOKE).meta(TIER2).page('https://getbootstrap.com/docs/4.1/components/alerts/')(
`Failed Test 4 Selector DNE with 2 screenshots`,
async t => {
await t.takeScreenshot();
await t.takeElementScreenshot(Selector('.alert'));
await t.expect(Selector('body').find('bar').exists).ok();
}
);
test.meta(SMOKE).meta(TIER2).page('https://getbootstrap.com/docs/4.1/components/alerts/')(
`Failed Test 5 Selector Click DNE`,
async t => {
await t.click(Selector('body').find('bar'));
}
);
fixture.meta(OWNERS)`Mixed Fixture`;
test.skip.meta(SMOKE).meta(TIER2)(`MF Skipped Test`, async () => {});
test.meta(SMOKE).meta(TIER2)(`MF Failed Test Selector DNE`, async t => {
await t.expect(Selector('bad').hasAttribute('bar')).ok();
});
[...Array(2).keys()].forEach(testNumber => {
test.meta(SMOKE).meta(TIER2).meta({
severity: 'critical',
story: 'I am a user story',
description: 'Checks something foo',
})(`Pass/Fail Test With ALL META ${testNumber}`, async t => {
await t.expect(testNumber % 2).eql(0);
});
});
fixture.meta(OWNERS)`Failing Fixture Setup`.beforeEach(async t => {
await t.click(Selector('baz'));
});
test.meta(SMOKE).meta(TIER2)(`FF Test`, async () => {});
fixture.meta(OWNERS)`Failing Assert Fixture`.beforeEach(async t => {
await t.expect(1).eql(0);
});
test.meta(SMOKE).meta(TIER2)(`FAF Test`, async () => {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment