Repository: codeceptjs/CodeceptJS (js)

Issue:
Second argument of I.say throw misleading error with invalid system color
#### What are you trying to achieve?

```javascript
I.say('Hello', 'orange');
```

throwing a "'orange' is not a valid terminal color"

#### What do you get instead?

```bash
Cannot read property 'bold' of undefined
```


### Details

* CodeceptJS version: 3.0.5
* NodeJS Version: 12.21.0
* Operating System: Ubuntu 20.04 through Windows 10 WSL2
* protractor
* Configuration file:

```js
{
  tests: '../projects/**/*.e2e.ts',
  output: '../output/e2e',
  timeout: 60000,
  helpers: {
    Protractor: {
      url: process.env.URL,
      driver: process.env.DRIVER,
      browser: process.env.BROWSER,
      rootElement: 'body',
      angular: false,
      getPageTimeout: 20000,
      allScriptsTimeout: 20000,
      restart: false,
      keepBrowserState: true,
      keepCookies: true,
      chromeDriver: '/usr/bin/chromedriver',
      seleniumAddress:  null,
      capabilities: {
        chromeOptions: {
          args: ['--no-sandbox', '--disable-web-security', '--ignore-certificate-errors']
        }
      }
   },
    Mochawesome: {
      uniqueScreenshotNames: 'true'
    }
  },
  mocha: {},
  name: 'xxx',
  mocha: {
    reporterOptions: {
      'codeceptjs-cli-reporter': {
        stdout: '-',
        options: {
          verbose: process.env.DEBUG == 'true' ? true : false,
          steps: true
        }
      },
      mochawesome: {
        stdout: '../output/e2e/console.log',
        options: {
          reportDir: '../output/e2e/mocha',
          reportFilename: 'index.html',
          charts: true,
          showSkipped: true,
          autoOpen: false
        }
      }
    }
  }
}
```


Pull request:
fix: Second argument of I.say throw misleading error with invalid system color
## Motivation/Description of the PR
- Resolves #2862 

## Type of change

- [ ] :fire: Breaking changes
- [ ] :rocket: New functionality
- [x] :bug: Bug fix
- [ ] :clipboard: Documentation changes/updates
- [ ] :hotsprings: Hot fix
- [ ] :hammer: Markdown files fix - not related to source code
- [ ] :nail_care: Polish code

## Checklist:

- [x] Tests have been added
- [ ] Documentation has been added (Run `npm run docs`)
- [ ] Lint checking (Run `npm run lint`)
- [x] Local tests are passed (Run `npm test`)


Patch:
diff --git a/lib/output.js b/lib/output.js
index 9be96277..0bda6a53 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -190,6 +190,9 @@ module.exports = {
    * @param {string} [color]
    */
   say(message, color = 'cyan') {
+    if (colors[color] === undefined) {
+      color = 'cyan';
+    }
     if (outputLevel >= 1) print(`   ${colors[color].bold(message)}`);
   },
 


Test patch:
diff --git a/test/unit/output_test.js b/test/unit/output_test.js
index f3feca6d..f296c7d7 100644
--- a/test/unit/output_test.js
+++ b/test/unit/output_test.js
@@ -53,6 +53,13 @@ describe('Output', () => {
     expect(console.log).to.have.been.calledTwice;
   });
 
+  it('should not throwing error when using non predefined system color for say function', () => {
+    const debugMsg = 'Dear Henrietta';
+
+    output.say(debugMsg, 'orange');
+    expect(console.log).to.have.been.called;
+  });
+
   afterEach(() => {
     console.log.restore();
   });