Socket
Socket
Sign inDemoInstall

@heartlandone/banner-ui

Package Overview
Dependencies
Maintainers
8
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@heartlandone/banner-ui

My Account Banner Components


Version published
Weekly downloads
669
decreased by-59.89%
Maintainers
8
Weekly downloads
 
Created
Source

My Account Components

Table of Contents

Overview

This package is mainly for creating custom web components built with stencil.js.

Prerequisite

Code linter

My account components is using eslint (config: .eslintrc.js) along with prettier (config: .prettierrc.js). Make sure both tools have been set up properly in your IDE.

Getting started

Install node dependencies

> npm install

Debug/Development

To generate a new stencil component

> npm run generate <element_tag>

Start local server to host preview your change for stencil components

> npm run start
# or 
> npm run debug # no cache

Testing

Currently, My account components has two testing environments:

  1. Unit test env:
    • In this env, we will run unit test for my account components / non-component logic (e.g. my-account-campagin.spec.tsx).
    • In this env, there won't be any actual HTML element during runtime and all of them will show up as MockHTMLElement
  2. E2E test env:
    • This env is using the exact browser runtime (Chromium) to run the test, which means all the UI/UX should be the same as the real one.
    • The tests we are running in this env are:
      1. E2E test for my account component classes (e.g. my-account-campagin.e2e.ts)

The command to run both <1> and <2> is

> npm run test
# or
> npm run test.watch # this command will re-run when src files are changed

If you want to run a single test suite, please run

> npm run test:single-suite <suite_file_name>

Example: npm run test:single-suite my-account-campagin.spec

If you want to run the specific test case within a single test suite, please run

> npm run test:single-case <test_case_name_regex>

Which will run only tests with a name that matches the regex. Example: npm run test:single-case "should render when set audience email"

If you would like to run is duplicate with the cases in other test suite, you can use the below command to specify the test case in a specific suite:

> npm run test:single-suite -- --testNamePattern <test_case_name_regex>

Note:

  1. The main difference between unit(spec) test vs e2e test in stencil can be found here
  • Once notice here is, unit test running in stencil is not behave the exact same as running it with jest CLI directly (especially for non-component test suite), this is because stencil is mocking most of the html element by using its own test runtime component, hence we would suggest avoiding using jest CLI directly to run unit tests as you might see different testing result when run it in Gitlab pipeline.
  1. In my account components, we prefer to put test case into spec/unit test over e2e test unless they are not able to test in non-browser env (e.g. simulate user blur/focus event, window resize), the main reason is stencil doesn't support to run test coverage over e2e test case, hence we cannot easily tell the branch inside component is covered properly by e2e test.
  2. In the scenario that you have to use e2e test to cover code branch, please use istanbul/ignoring-code-for-coverage and put additional comment regarding how this branch is covered in e2e test to skip the code for coverage checking. For example:
    • in src/components/my-account-campaign/my-account-campaign.tsx
      // ...
      
       /**
         * The below method is e2e-test covered in
         * @see{module:my-account-campaign-listen-vegaLoad-e2e}
         */
         /* istanbul ignore next */
         private didLoadCampaigns = () => {
             this.campaignItems.forEach(async (campaign: BannerViewData) => {
                 await sendAudienceActivity(campaign, 'LOAD', this.audienceEmail, this.apimSubscriptionKey);
             });
         };
      
      // ...
      
    • and the jsdoc module module:my-account-campaign-listen-vegaLoad-e2e is defined in src/components/my-account-campaign/test/my-account-campaign.e2e.ts
      // ...
      
         describe('my-account-campaign', () => {
             /** @module my-account-campaign-listen-vegaLoad-e2e */
             it('should emit vegaLoad event when render vega-banner', async () => {
                 await page.setContent(`<my-account-campaign apim-subscription-key="key"></my-account-campaign>
             `);
                 const vegaLoadEvent: EventSpy = await page.spyOnEvent('vegaLoad');
                 await page.waitForChanges();
                 const element: E2EElement = await page.find('my-account-campaign');
                 element.setProperty('audienceEmail', 'test@123.com');
                 await page.waitForChanges();
                 expect(vegaLoadEvent).toHaveReceivedEventTimes(1);
             });
         });
      
        // ...
      

Raising a commit

Make sure you have passed the necessary pre commit check by running

> npm run test

Once the above command succeeded, run this command to build the artifacts for releasing

> npm run lint 

Troubleshooting

1. E2E Testing Failure due to the css not loaded

This is because the current stencil build in your workspace is staled and you need to re-build the artifacts by running npm run build.

FAQs

Package last updated on 05 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc