Skip to content

Commit

Permalink
Creating annotations for failed e2e tests (OctoLinker#1063)
Browse files Browse the repository at this point in the history
  • Loading branch information
xt0rted authored Oct 6, 2020
1 parent 8827d39 commit 45db857
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
37 changes: 26 additions & 11 deletions e2e/automated.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ async function executeTest(url, targetUrl, selector) {
await page.waitForSelector(`${selector}[href$="${targetUrl}"]`);
}

function createAnnotation({ file, lineNumber, ex }) {
// eslint-disable-next-line no-console
console.log(`::error file=${file},line=${lineNumber}::${ex.message}`);
}

describe('End to End tests', () => {
beforeAll(async () => {
if (!process.env.E2E_USER_NAME || !process.env.E2E_USER_PASSWORD) {
Expand Down Expand Up @@ -48,25 +53,35 @@ describe('End to End tests', () => {
});

describe('single blob', () => {
fixtures.forEach(({ url, content, lineNumber, targetUrl }) => {
fixtures.forEach(({ url, file, content, lineNumber, targetUrl }) => {
if (targetUrl === false) {
it(`does not resolve ${content}`, async () => {
await executeTest(
url,
targetUrl,
`#LC${lineNumber} .octolinker-link`,
);
try {
await executeTest(
url,
targetUrl,
`#LC${lineNumber} .octolinker-link`,
);
} catch (ex) {
createAnnotation({ file, lineNumber, ex });
throw ex;
}
});
return;
}

it(`resolves ${content} to ${targetUrl}`, async () => {
if (lineNumber) {
await executeTest(
url,
targetUrl,
`#LC${lineNumber} .octolinker-link`,
);
try {
await executeTest(
url,
targetUrl,
`#LC${lineNumber} .octolinker-link`,
);
} catch (ex) {
createAnnotation({ file, lineNumber, ex });
throw ex;
}
} else {
await executeTest(
url,
Expand Down
1 change: 1 addition & 0 deletions e2e/generate-fixtures-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function findTests(contents) {

memo.push({
url: `${fixturesRoot}${filePath}`,
file: `e2e${filePath}`,
content: lines[index + 1].trim(),
targetUrl,
lineNumber,
Expand Down

0 comments on commit 45db857

Please sign in to comment.