npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@heartlandone/vega-sandbox-pr-1455-e49edb70a46f04931b505016552bbe8b9e9ee030

v2.28.0

Published

Vega - the design system of Heartland Payment Systems

Downloads

82

Readme

vega-stencil

Table of Contents

Overview

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

Prerequisite

Code linter

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

[Optional] Consume new design token

design token was originally stored at ../vega-design package which is also responsible for generating corresponding CSS/JS file used by other clients including vega-stencil.

Hence, if you want to test some change of design token and want to integrate them into vega-stencil, you need to re-run the consume command to fetch the CSS/JS files from vega-design to vega-stencil:

> npm run consume-design-token

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

To view the change in storybook

> npm run storybook

Testing

Currently, vega-stencil has two testing environments:

  1. Unit test env:
    • In this env, we will run unit test for vega components / non-component logic (e.g. vega-badge.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 vega component classes (e.g. vega-badge.e2e.ts)
      2. E2E test for visual regression checking (e.g. vaga-date-picker.visual.e2e.ts)
      3. E2E test for accessibility checking with standard 'wcag2a', 'wcag2aa','wcag21a', 'wcag21aa' (e.g. vega-date-picker.ada.e2e.ts)

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

> npm run test:base:coverage
# or
> npm run test:base:watch-all # this command will re-run when src files are changed

The command to run visual regression test only is

> npm run test:visual 

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 vega-modal.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 proper css of modal when open modal"

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>

If you need to update component images,pls delete the related object in master.json,then run below command and commit the changes:

1.<3> 2.node scripts/visual-test-screenshot-handle.js

If you want to see the difference pic between local and stand,pls follow below step:

1.install Live Server extension 2.open screenshot/compare.html by open with Live Server 3.choose All Screenshots on right top 4.click blank area under left side if the stand pic not show ,and manuel compare it

If you want to disable Featureflag to test cases with old logic:

For e2e test to disable a featureflag:

describe('vega-input', () => {
  let page: E2EPage;
  beforeEach(async () => {
      page = await newE2EPage();
      await page.evaluateOnNewDocument(() => {
          window['VegaDisabledFeatureKeys'] = ['VEGA_FORM.FORM_FIELD_CONTROLLER_VALIDATION'];
      });
  });

For spec test to disable a featureflag:

describe('vega-input', () => {
  beforeAll(() => {
    FeatureFlag.disable('VEGA_FORM.FORM_FIELD_CONTROLLER_VALIDATION');
});

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 Github pipeline.
  1. In vega, 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 vega-stencil/src/components/vega-carousel/vega-carousel.tsx
      // ...
           
      /**
      * The below method is e2e-test covered in
      * @see{module:vega-carousel-e2e-render}
      */
      /* istanbul ignore next */
      @Watch('perPage')
      onPerPagePropsChange(): void {
        this.resizeWindowHelper();
        this.applySpacingHelper();
      }
           
      // ...
    • and the jsdoc module module:vega-carousel-e2e-render is defined in vega-stencil/src/components/vega-carousel/test/vega-carousel.e2e.ts
      describe('vega-carousel', () => {
        /** @module vega-carousel-e2e-render */
        it('renders', async () => {
          const page: E2EPage = await newE2EPage();
          await page.setContent('<vega-carousel></vega-carousel>');
          const element: E2EElement = await page.find('vega-carousel');
          expect(element).toHaveClass('hydrated');
        });
      });

Raising a commit

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

> npm run pre-release

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

> npm run release 

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 yarn run release.