diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 59c69cd..8e7e331 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -24,5 +24,5 @@ jobs: run: yarn - name: lint run: yarn lint - - name: build & test - run: yarn build && yarn test + - name: test + run: yarn test diff --git a/README.md b/README.md index 60861ef..a139469 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,80 @@ ![Build](https://github.com/HugoDF/buttondown/workflows/Build%20&%20test/badge.svg) -microbundle-ts-pkg: A TypeScript npm package skeleton/starter project with microbundle, AVA and XO +Utilities for testing Alpine.js components. -Comes with: +**This library allows you to quickly and easily write tests for Alpine.js applications via Node.js using any testing library.** -- [SAMPLE_README.md](./SAMPLE_README.md) and [USE_CASES.md](./USE_CASES.md) for documentation. -- AVA for testing (see [./tests](./tests)) -- XO for linting/formatting -- microbundle for compiling TypeScript to UMD, ESM, CJS +This project is not officially affiliated with Alpine.js, it's maintained by community members. For any feedback, questions or issues, please create [issues](https://github.com/HugoDF/alpine-test-utils/issues) and [pull requests](https://github.com/HugoDF/alpine-test-utils/blob/master/README.md#contributing) or merely upvote or comment on existing issues or pull requests. + +# Table of Contents + +- [Table of Contents](#table-of-contents) +- [Installation](#installation) + - [Prerequisites](#prerequisites) + - [Install Package](#install-package) +- [Quick Start, Create a Draft](#quick-start-create-a-draft) +- [Roadmap](#roadmap) +- [Contributing](#contributing) + - [Requirements](#requirements) + - [Setup](#setup) + - [npm scripts](#npm-scripts) +- [About](#about) + - [Acknowledgments](#acknowledgments) +- [LICENSE](#license) + +# Installation + +## Prerequisites + +- Node.js version 10 or 12 + +## Install Package + +The following recommended installation requires [npm](https://npmjs.org/). If you are unfamiliar with npm, see the [npm docs](https://npmjs.org/doc/). Npm comes installed with Node.js since node version 0.8.x, therefore, you likely already have it. + +```sh +npm install --save-dev alpine-test-utils +``` + +You may also use [yarn](https://yarnpkg.com/en/) to install. + +```sh +yarn add --dev alpine-test-utils +``` + +> **Note**: if you're using Alpine.js from CDN you will also need to install it using npm or Yarn + +```sh +npm install --save alpinejs +# or for Yarn users +yarn add alpinejs +``` + + +# Quick Start, Create a Draft + +Here's an example to render an Alpine.js component that's situated in the `test.html` file: + +```js +import {load, render} from 'alpine-test-utils'; + +test('render and override x-data', () => { + const componentHtml = `
+ +
` + const component = render(componentHtml, { foo: 'world' }); + expect(component.querySelector('span').innerText).toEqual('world'); +}); +``` + +For more complex use cases, please see [USE_CASES.md](./USE_CASES.md). + + +# Roadmap + +If you are interested in the future direction of this project, please take a look at the open [issues](https://github.com/HugoDF/microbundle-ts-pkg/issues) and [pull requests](https://github.com/HugoDF/microbundle-ts-pkg/pulls). I would love to hear your feedback! + +# Contributing ## Requirements diff --git a/SAMPLE_README.md b/SAMPLE_README.md deleted file mode 100644 index 065a653..0000000 --- a/SAMPLE_README.md +++ /dev/null @@ -1,124 +0,0 @@ -![Build](https://github.com/HugoDF/buttondown/workflows/Build%20&%20test/badge.svg) - -DESCRIBE THE LIBRARY - -LINK TO OTHER RESOURCES - -**This library allows you to quickly and easily do @todo via Node.js.** - -This project is not officially affiliated with @todo, it's maintained by community members. For any feedback, questions or issues, please create [issues](https://github.com/HugoDF/microbundle-ts-pkg/issues) and [pull requests](https://github.com/HugoDF/microbundle-ts-pkg/blob/master/README.md#contributing) or merely upvote or comment on existing issues or pull requests. - -# Table of Contents - -- [Table of Contents](#table-of-contents) -- [Installation](#installation) - - [Prerequisites](#prerequisites) - - [Obtain an API Key](#obtain-an-api-key) - - [Setup Environment Variables](#setup-environment-variables) - - [Install Package](#install-package) -- [Quick Start, Create a Draft](#quick-start-create-a-draft) -- [Roadmap](#roadmap) -- [Contributing](#contributing) - - [Requirements](#requirements) - - [Setup](#setup) - - [npm scripts](#npm-scripts) -- [About](#about) - - [Acknowledgments](#acknowledgments) -- [LICENSE](#license) - -# Installation - -## Prerequisites - -- Node.js version 10 or 12 - - -## Obtain an API Key - -Grab your API Key from the [@todo](@todo). - -## Setup Environment Variables - -Do not hardcode your [API Key](@todo) into your code. Instead, use an environment variable or some other secure means of protecting your API Key. Following is an example of using an environment variable. - -Update the development environment with your [@todo](@todo), for example: - - - -## Install Package - -The following recommended installation requires [npm](https://npmjs.org/). If you are unfamiliar with npm, see the [npm docs](https://npmjs.org/doc/). Npm comes installed with Node.js since node version 0.8.x, therefore, you likely already have it. - -```sh -npm install --save @todo -``` - -You may also use [yarn](https://yarnpkg.com/en/) to install. - -```sh -yarn add @todo -``` - - -# Quick Start, Create a Draft - -The following is the minimum needed code to use this library. Use this example, and modify the `to` and `from` variables: - -For more complex use cases, please see [USE_CASES.md](./USE_CASES.md). - - -# Roadmap - -If you are interested in the future direction of this project, please take a look at the open [issues](https://github.com/HugoDF/microbundle-ts-pkg/issues) and [pull requests](https://github.com/HugoDF/microbundle-ts-pkg/pulls). I would love to hear your feedback! - -# Contributing - -## Requirements - -- Node 10 -- Yarn 1.x or npm - -## Setup - -1. Clone the repository -2. Run `yarn` or `npm install` installs all required dependencies. -3. Run `yarn build` to build from TypeScript to common JavaScript distribution formats. -4. Run `yarn test` to run all tests :D. - -## npm scripts - -> Equivalent `npm run