From 12c0793217a2bc9cfde86cffb29627ffc1a9195b Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Tue, 9 Mar 2021 16:49:47 -0400 Subject: [PATCH] add token to calls, remove block from test title --- tests/e2e/env/src/setup/jest.failure.js | 8 +++----- tests/e2e/env/src/slack/reporter.js | 6 ++++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/e2e/env/src/setup/jest.failure.js b/tests/e2e/env/src/setup/jest.failure.js index de8c655ec2e..31a906a10ee 100644 --- a/tests/e2e/env/src/setup/jest.failure.js +++ b/tests/e2e/env/src/setup/jest.failure.js @@ -14,7 +14,6 @@ const { getAppRoot } = require( '../../utils' ); * * See: https://github.com/smooth-code/jest-puppeteer/issues/131#issuecomment-469439666 */ -let currentBlock; /** * We need to reference the original version of Jest. @@ -28,7 +27,6 @@ const originalIt = global.it; */ global.describe = (() => { const describe = ( blockName, callback ) => { - currentBlock = blockName; try { originalDescribe( blockName, callback ); @@ -61,7 +59,7 @@ global.describe = (() => { */ global.it = (() => { const test = async ( testName, callback ) => { - const testCallback = async () => screenshotTest( currentBlock, testName, callback ); + const testCallback = async () => screenshotTest( testName, callback ); return originalIt( testName, testCallback ); }; const only = ( testName, callback ) => { @@ -86,11 +84,11 @@ global.it = (() => { * @param callback * @returns {Promise} */ -const screenshotTest = async ( blockName, testName, callback ) => { +const screenshotTest = async ( testName, callback ) => { try { await callback(); } catch ( e ) { - const testTitle = `${ blockName } - ${ testName }`.replace( /\.$/, '' ); + const testTitle = testName.replace( /\.$/, '' ); const appPath = getAppRoot(); const savePath = path.resolve( appPath, 'tests/e2e/screenshots' ); const filePath = path.join( diff --git a/tests/e2e/env/src/slack/reporter.js b/tests/e2e/env/src/slack/reporter.js index fedb5593280..9c63467e668 100644 --- a/tests/e2e/env/src/slack/reporter.js +++ b/tests/e2e/env/src/slack/reporter.js @@ -73,11 +73,12 @@ export async function sendFailedTestMessageToSlack( testName ) { try { // For details, see: https://api.slack.com/methods/chat.postMessage await web.chat.postMessage({ + channel: E2E_SLACK_CHANNEL, + token: E2E_SLACK_TOKEN, text: `Test failed on *${ pr.branch }* branch. \n The commit this build is testing is *${ pr.commit }*. \n The name of the test that failed: *${ testName }*. \n See screenshot of the failed test below. *Build log* could be found here: ${ pr.webUrl }`, - channel: E2E_SLACK_CHANNEL, }); } catch ( error ) { // Check the code property and log the response @@ -107,9 +108,10 @@ export async function sendFailedTestScreenshotToSlack( screenshotOfFailedTest ) try { // For details, see: https://api.slack.com/methods/files.upload await web.files.upload({ + channels: E2E_SLACK_CHANNEL, + token: E2E_SLACK_TOKEN, filename, file: createReadStream( screenshotOfFailedTest ), - channels: E2E_SLACK_CHANNEL, }); } catch ( error ) { // Check the code property and log the response