0

My .testcaferc.json file looks like this

{ "reporter": [ { "name": "spec" }, { "name": "slack-custom", "options": { "webhookUrl": "https://hooks.slack.com/services/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", "loggingLevel": "SUMMARY_WITH_ERRORS", "channel": "#auto-testing", "username": "testcafebot", "alertChannelOnError": true } } ] }

Can someone suggest to me what variable do I need to add in .testcaferc.json

enter image description here

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Arvind
  • 17
  • 2

2 Answers2

1

Add the testingEnvironment option to your .testcaferc.json file:

{ "reporter": [ { "name": "spec" }, { "name": "slack-custom", "options": { "webhookUrl": "https://hooks.slack.com/services/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", "loggingLevel": "SUMMARY_WITH_ERRORS", "channel": "#auto-testing", "username": "testcafebot", "alertChannelOnError": true, "testingEnvironment": "args.env" } } ] }

Or use the TESTCAFE_SLACK_TEST_ENV=args.env variable.

Pavel Avsenin
  • 254
  • 1
  • 2
1

I have attached a simple example that works on my side. Would you please download it, run the 'testcafe' command and check whether it works correctly for you.

test.js

import { Selector } from 'testcafe';

fixture`A set of examples that illustrate how to use TestCafe API`
    .page`http://devexpress.github.io/testcafe/example/`;


const developerName = Selector('#developer-name');

test('How to type text into an input (t.typeText user action)', async t => {
    await t
        .typeText(developerName, 'Peter')
        .typeText(developerName, 'Paker', { replace: true })
        .typeText(developerName, 'r', { caretPos: 2 })
        .expect(developerName.value).eql('Parker');
});

.testcaferc.json

{
    "browsers": ["chrome"],
    "src": ["test.js"],
    "reporter": [
        { "name": "spec" }, 
        { "name": "slack-custom", 
            "options": { 
                "webhookUrl": "https://hooks.slack.com/services/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",
                "testingEnvironment": "args.env"
            }
        }
    ]
}

package.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "test.js",
  "author": "",
  "license": "",
  "dependencies": {
    "testcafe": "^1.14.0",
    "testcafe-reporter-slack-custom": "^1.3.0"
  },
  "devDependencies": {}
}
Pavel Avsenin
  • 254
  • 1
  • 2
  • Still it is not working I am getting like this Screenshot 1943-04-22 at 5.49.45 PM ---- START OF TEST RUN ---- :rocket: Started TestCafe: 7/13/2021 5:49:25 pm :computer: Ran 1 tests in: Chrome 91.0.4472.114 / macOS 10.15.7 :earth_americas: Test Environment: args.env :checkered_flag: Testing finished at 7/13/2021 5:49:32 pm :stopwatch: Duration: 8s :white_check_mark: 1/1 passed ----- END OF TEST RUN ----- – Arvind Jul 13 '21 at 12:20
  • It seems to be the correct behavior. The ":earth_americas: Test Environment: args.env" displays the value of the testingEnvironment option (OR the value of the TESTCAFE_SLACK_TEST_ENV environment variable) and it shows you the value of your testingEnvironment option: args.env. For additional research you can see the sources: [github.com/zwagner86/testcafe-reporter-slack-custom/blob/master/…](https://github.com/zwagner86/testcafe-reporter-slack-custom/blob/master/src/index.js) or create an issue here https://github.com/zwagner86/testcafe-reporter-slack-custom/issues. – Pavel Avsenin Jul 14 '21 at 07:52