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

aframe-machinima-testing

v0.1.2

Published

Utilities for automated functional testing in A-Frame scenes and components

Downloads

29

Readme

aframe-machinima-testing

npm Version

Utilities for automated functional testing in A-Frame scenes and components using motion-captured user input.

Demo GIF

Installation

Install from npm into your package:

npm install --save-dev aframe-machinima-testing

There is a long list of peer dependencies including aframe-motion-capture-components and all the pieces for Karma-Mocha-Chai testing. The install command below will get you up to speed with compatible versions of each.

npm install --save-dev  aframe-motion-capture-components@git+https://[email protected]/wmurphyrd/aframe-motion-capture-components.git#v0.2.8a chai@^4.1.2 karma@^1.7.1 karma-browserify@^5.1.1 karma-chrome-launcher@^2.2.0 karma-firefox-launcher@^1.0.1 karma-html2js-preprocessor@^1.1.0 karma-mocha@^1.3.0 [email protected] karma-sinon-chai@^1.3.2 mocha@^3.5.3 sinon@^2.1.0 sinon-chai@^2.13.0

Note: temporarily linking to a fork of the motion capture components until a patch lands in the next release.

Usage: Workflow

Machinima tests can be run just like other automated tests. They will replay recorded user actions in an A-Frame scene and allow you to check assertions against the resulting scene state. Running machinima tests requires some package structure, Karma configuration, and specific calls in your Mocha tests.

This package includes the machinima-bootstrap command line tool to setup the necessary package structure and karma.config.js and also exports helper functions to streamline the process of writing Mocha tests.

Once setup, the workflow is:

  1. Add HTML A-Frame scenes to machinima_tests/scenes
  2. Use the npm run record:machinima command to load the scenes and record motion-captured user actions
  3. Save the recordings in recordings in machinima_tests/recordings
  4. Create tests in machinima_tests/tests that replay the recordings in the scenes and run assertions on the resulting state
  5. Use the npm run test:machinima command to run the tests

Usage: machinima-bootstrap CLI

The package includes a CLI to add the necessary configuration for automated functional testing in your NodeJS package. You can call it from the local installation with the commend below:

node_modules/.bin/machinima-bootstrap

This will install a set of templates in ./machinima_tests and you will be ready to run the example tests with:

npm run test:machinima

Load up your scenes to make new recordings with the following command:

npm run record:machinima

Once in the scene, use the spacebar to start and stop recording, and save the files to the machinima_tests/recordings folder.

Usage: test API

const machinima = require('aframe-machinima-testing');

Access the helper functions by including the package in test scripts.

machinima.test(description, recordingFile, postReplay, preReplay)

A wrapper for Mocha's test that sets the recording to play and runs assertions after the playback finishes. .test.only() and .test.skip() variants are included to set the only or skip flag on the underlying Mocha test call.

| Argument | Description | | --- | --- | | description | String. Test label | | recordingFile | String. Path to recording file to play (as served by Karma) | | postReplay (optional) | Function. Code/assertions to run after the recording completes | | preReplay (optional) | Function. Code/assertions to run before the recording begins |

The postReplay and preReplay functions are called with this set to the Mocha test context, and objects added to this in preReplay will be available in postReplay.

machinima.setupScene(sceneFile)

Should be called inside each suite's setup call to inject the A-Frame scene into the test document.

| Argument | Description | | --- | --- | | sceneFile | String. Name of html file in the machinima_tests/scenes/ folder and prepared by karma-html2js-preprocessor |

machinima.teardownReplayer()

Should be called inside the global or suite teardown call to help avatar-replayer clean-up.

Lower-level API

In cases where the .test wrapper doesn't suit your needs, you can use these lower-level functions inside a Mocha test call to run the machinima test.

machinima.testStart(testContext, recordingFile)

Disables the test timeout and activates avatar-replayer.

| Argument | Description | | --- | --- | | testContext | Pass in the this object of your test function | | recordingFile | Path to motion capture JSON file in the machinima_tests/scenes/ and served by Karma |

machinima.testEnd(callback)

Sets callback as an event listener for when the recording is finished replaying. Requires asynchronous testing, so your Mocha test function needs to take the done argument and it should be called from inside your callback.

| Argument | Description | | --- | --- | | callback | Function |