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

@amaui/test

v1.1.3

Published

Test suite for front end and back end

Downloads

56

Readme

Getting started

Add

  yarn add @amaui/test --dev

Use

Nodejs

You can have amaui-test options either in package.json in 'amaui-test' property or amaui-test.options.js file in root directory, where amaui-test command will be made.

In nodejs on amaui-test run errors amaui-test exits the process, so it's all good if the command is flow dependent.

amaui-test.options.js

  module.exports = {
    imports: [
      'ts-node/register/transpile-only'
    ],
    files: [
      'test/**/*.test.ts'
    ]
  }

or

package.json

  {
    "scripts": {
      test: "amaui-test"
    },
    "amaui-test": {
      imports: [
        'ts-node/register/transpile-only'
      ],
      files: [
        'test/**/*.test.ts'
      ]
    }
  }

And with yarn test or npm test command amaui-test will run all the tests based on the amaui-test options

  yarn test

Browser

Make an AmauiTest instance, which will prepare the environment, write all the tests below it, and run the tests with amauiTest.run() method, which on errors throws an error, so if the tests passing is flow dependent, running tests will obviously stop the method having thrown an error on tests not having passed.

  import { AmauiTest, assert } from '@amaui/test';
  import { wait } from '@amaui/utils';

  const amauiTest = new AmauiTest();

  to('a', () => {
    assert(4).eq(4);
  });

  group('@amaui/a1', () => {

    pre(async () => {
      await wait(140);

      throw new Error('a');
    });

    to('a2', async () => {
      await wait(140);

      assert(4).eq(4);
    });

    group('@amaui/a3', () => {

      to('a3', async () => {
        assert(function a() { }).eq(undefined);
      });

    });

    to('a4', () => {
      [1, 2, 3, 4].forEach(value => {
        assert(typeof value === 'number').true;

        throw new Error('a');
      });
    });

    group('@amaui/a5', () => {
      let a: any;

      pre(async () => {
        await wait(14);
      });

      preTo(async () => {
        await wait(140);

        a = 4;
      });

      to('a5', (resolve, reject) => {
        const error: any = new Error();

        // Added expected and expression message
        error.name = 'An Error';
        error.expected = 4;
        error.expression = 'to be 🍊';

        reject(error);
      });

    });

    to('a6', async () => {
      await wait(74);

      assert(4).eq(4);
    });

    to('a7', async () => {
      assert(['padding-left', 'padding', 'padding-right']).eql(['padding', 'padding-left', 'padding-right']);
    });

    to('a8', async resolve => {
      await wait(4);

      resolve();

      await wait(140);

      assert(4).eq(4);
    });

    to('a9', async () => {
      await assert(function a() { }).throwAsync(4);
    });

    to('a10', async () => {
      assert({
        "direction": "ltr",
        "preference": {
          "background": {
            "default": "neutral"
          },
          "text": {
            "default": "neutral"
          },
          "visual_contrast": {
            "default": "regular"
          }
        },
        "mode": "regular",
        "palette": {
          "accessibility": "regular",
          "visual_contrast": {
            "low": {
              "opacity": {
                "primary": 0.77,
                "secondary": 0.54,
                "tertiary": 0.27
              }
            }
          }
        }
      }).eql({
        "direction": "ltl",
        "preference": {
          "background": {
            "default": "neutral"
          },
          "text": {
            "default": "neutral"
          },
          "visual_contrast": {
            "default": "regular"
          }
        },
        "mode": "regular",
        "palette": {
          "accessibility": "regular",
          "visual_contrast": {
            "low": {
              "opacity": {
                "primary": 0.77,
                "secondary": 0.54,
                "tertiary": 0.27
              }
            }
          }
        }
      });
    });

    to('a11', async () => {
      const value = [
        'AmauiError',
        'AmauiError',
        'AmauiAwsError',
        'AmauiTestError',
        'AmauiAmqpError',
        'AuthenticationError',
        'AuthorizationError',
        'AssertError',
        'ValidationError',
        'PermissionError',
        'AmauiMongoError',
        'ConnectionError',
        'NotFoundError',
        'DeveloperError',
        'AmauiError',
      ];
      const value1 = [
        'AmauiError',
        'AmauiError',
        'AmauiAwsError',
        'AmauiTestError',
        'AmauiAmqpError',
        'AuthenticationError',
        'AuthorizationError',
        'ValidationError',
        'PermissionError',
        'AmauiMongoError',
        'ConnectionError',
        'NotFoundError',
        'DeveloperError',
        'AmauiError',
      ];

      assert(value).eql(value1);
    });

    to('a12', async () => {
      const value = {
        a: {
          a: {
            a: {
              ab: 4,
            },
          },
          ab: 4,
        },
      };
      const value1 = {
        a: {
          a: {
            b: 4,
            a: {
              ab: 5,
              ac: 4,
            },
          },
        },
        ab: [1, 2, 3, 4],
      };

      assert(value).eql(value1);
    });

    to('a13', async () => {
      assert(4).eq(4);
    });

    post(async () => {
      await wait(40);
    });

  });

  to('a14', async () => {
    assert(timezones).eql([{ a: [function a() { }, { a: 4 }, 4] }]);
  });

  await amauiTest.run();

Results logged in nodejs and browser (and with an option for HTML logs)

AmauiTest results

Dev

Install

  yarn

Test

  yarn test

Prod

Build

  yarn build