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

@alotela/mf-maestro-tester

v0.0.12

Published

a tool to test and develop MfMaestro compatible microfrontends

Downloads

5

Readme

MfMaestro tester

A tool to develop MfMaestro compatible microfrontends without MfMaestro.
It simulates a store and events so that you can use all MfMaestro features when developing your MF in an isolated page.
Just register your app as you would do (window.MfMaestro.registerMicroApp("micro-app", {start, stop}). In your html page's header, add the script node to load it:
<script src="https://unpkg.com/[email protected]/dist/index.js">
and put an id equal to the registered name ("micro-app") on the div where you want to start your application:
<div id="micro-app"></div>

If you want to emit events listened by your MF, open the console and type:

window.MfMaestro.events.emit("your event name", yourparams...)

You can also add callbacks to listen some events with the on method:
window.MfMaestro.events.on("your event name", callback)

When your Mf is started by MfMaestro, the start function receives params and options. If you want to inject params into your MF (url params), you can add a "params" argument to your page's query string, with a json5 payload: http://localhost:3000/index.html?params={id:12,sub-id:12344}

You can also add queryParams available in options using the query argument : http://localhost:3000/index.html?query={order:asc,page:2}

You can use both at the same time to inject in params and options as MfMaestro would do.

If you need to inject params and want it to be always activated, you can add a script node before loading the tester in your page:

<script>
MfMaestroAppParams={a:1, b: 2};
</script>

This will be merged with params from query string.

events queue for tests

All emitted events are logged in a queue available on window.MfMaestro.outputEventsQueue. An event is logged as a tuple [event, args] (string, array).
If you want to test for an event, you can use window.MfMaestro.eventHasBeenEmitted(event, args, options).
Args is an array with all args you passed to emit, AFTER the event name. Since it is optional, if you don't specify it, and call window.MfMaestro.eventHasBeenEmitted(event), it will be equal to an empty array.
Options is optional and accepts these attributes:

  • count : the number of times you expect the event has been emitted

You can have a look at the tests/test.js to find examples.

navigation

you can test for navigations block/unblock with these methods:

  • window.MfMaestro.isNavigationBlocked("myContext")
  • window.MfMaestro.isNavigationUnblocked("myContext")

When you call options.navigation.blockNavigation() or options.navigation.unblockNavigation(), just pass a context as arg. It will do nothing in MfMaestro, but will allow to test that navigation block/unblock have been called.