anorexia
TypeScript icon, indicating that this package has built-in type declarations

0.4.1 • Public • Published

Travis

anorexia

An experimental automation tool for Angular

This project is separated from learn angular the hard way, acting as an automation tool to mimic the human behaviours.

It is now used to confirm if the steps listed in a tutorial is working fine, and not breaking in newer versions. (with cron task in CI)

Important Notes

This project is currently for personal use only, there will be more documentation when it become stable and public.

Usage

Install via npm:

npm install anorexia --save-dev

Create a playbook:

// playbook.ts

import { playbook, stage } from 'anorexia'
import { assert } from 'chai'

playbook('playbook-name', async (host) => {

  const { angular: ng, javascript: js, yarn, system, file, json } = host.extensions
  
  stage('installing dependencies example', () => {
    yarn.install()
  })

  stage('creating files example', () => {
    // Copy files from PROJECT to WORKSPACE
    host.setUpFiles({
      [`fixtures/main.ts`]: `src/main.ts`,
      [`fixtures/tsconfig.json`]: `tsconfig.json`,
      [`fixtures/package.json`]: `package.json`,
    })
  })

  stage('building example', () => {
    system.exec('tsc -p .')
  })

  stage('verifying example', () => {
    assert.isTrue(file.exists('dist/main.js'))
  })

  stage('modifying example', () => {
    file.remove('dist/main.js')
    json.modify('tsconfig.json', {
      compilerOptions: {
        outDir: 'target'
      }
    })
  })

  stage('verifying example', () => {
    assert.isTrue(file.exists('target/main.js'))
  })

  stage('replacing example', () => {
    file.replaceInFile('dist/main.js',
      [`environment.production`, 'true'],
      [`debugger`, ''],
    )
  })

  await stage('verifying Angular app example', () => {
    const html = await ng.renderToHtml()
    assert.match(html, /Hello Angular/)
    system.echo('app works!')
  })

}, __dirname)

Execute the playbook

ts-node playbook.ts

Readme

Keywords

none

Package Sidebar

Install

npm i anorexia

Weekly Downloads

14

Version

0.4.1

License

MIT

Last publish

Collaborators

  • trotyl