Skip to content

New test harness for HTML-based tests#3012

Merged
compulim merged 17 commits intomicrosoft:masterfrom
compulim:feat-html-test
Apr 2, 2020
Merged

New test harness for HTML-based tests#3012
compulim merged 17 commits intomicrosoft:masterfrom
compulim:feat-html-test

Conversation

@compulim
Copy link
Copy Markdown
Contributor

@compulim compulim commented Mar 13, 2020

Changelog Entry

Description

HTML-based test is easier to write and debug than WebDriver tests.

We are not removing WebDriver from the test harness because we still need some help for grabbing image snapshots.

To-do

  • Add code coverage

Sample HTML-based tests

/**
 * @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js
 */

describe('offline UI', () => {
  test('should show "unable to connect" UI when credentials are incorrect', () =>
    runHTMLTest('offlineUI.invalidCredentials.html'));
});
<!DOCTYPE html>
<html lang="en-US">
  <head>
    <script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone@7/babel.min.js"></script>
    <script crossorigin="anonymous" src="https://unpkg.com/regenerator-runtime/runtime.js"></script>
    <script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.development.js"></script>
    <script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.development.js"></script>
    <script
      crossorigin="anonymous"
      src="https://unpkg.com/[email protected]/umd/react-dom-test-utils.development.js"
    ></script>
    <script crossorigin="anonymous" src="/__dist__/testharness.js"></script>
    <link href="/assets/index.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <div id="webchat"></div>
    <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
    <script type="text/babel" data-presets="es2015,stage-3">
      const { conditions, createStore, host, pageObjects, timeouts } = window.WebChatTest;

      (async function() {
        window.WebChat.renderWebChat(
          {
            directLine: window.WebChat.createDirectLine({ token: 'INVALID-TOKEN' }),
            store: createStore(),
            styleOptions: { spinnerAnimationBackgroundImage: 'url(/assets/staticspinner.png)' }
          },
          document.getElementById('webchat')
        );

        await pageObjects.wait(conditions.webChatRendered(), timeouts.ui);
        await pageObjects.wait(conditions.actionDispatched('DIRECT_LINE/CONNECT_REJECTED'), timeouts.directLine);

        await host.snapshot();
        await host.done();
      })().catch(async err => {
        console.error(err);

        await host.error(err);
      });
    </script>
  </body>
</html>

Specific Changes


  • Testing Added

@compulim compulim changed the title [DRAFT] New test harness for HTML-based tests New test harness for HTML-based tests Mar 14, 2020
@compulim compulim marked this pull request as ready for review March 14, 2020 08:53
@corinagum corinagum self-assigned this Mar 31, 2020
Comment thread packages/testharness/src/pageObjects/typeOnSendBox.js
Comment thread __tests__/html/__jest__/mergeCoverageMap.js Outdated
Comment thread __tests__/html/__jest__/mergeCoverageMap.js Outdated
Comment thread packages/testharness/src/utils/runAsyncInterval.js
Comment thread __tests__/setup/setupTestFramework.js
Comment thread jest.config.js Outdated
Comment thread __tests__/html/offlineUI.slowNetwork.reconnect.html Outdated
Comment thread __tests__/html/offlineUI.firstConnect.html Outdated
Copy link
Copy Markdown
Contributor

@corinagum corinagum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See nitpicks

@compulim compulim merged commit 99e0267 into microsoft:master Apr 2, 2020
@compulim compulim deleted the feat-html-test branch April 2, 2020 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants