How to use ava - 10 common examples

To help you get started, we’ve selected a few ava examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github johnwebbcole / jscad-utils / test / array.js View on Github external
import test from 'ava';
// import { nearlyEqual } from './helpers/nearlyEqual';
import * as array from '../src/array';

test('import array', t => {
  // console.log(
  //     Object.keys(array)
  //         .map(k => `test.todo('${k}');`)
  //         .join('\n')
  // );

  t.snapshot(Object.keys(array));
});

test.todo('div');
test.todo('addValue');
test.todo('addArray');
test.todo('add');
test.todo('fromxyz');
test.todo('toxyz');
test.todo('first');
test.todo('last');
test.todo('min');
test.todo('range');
github functional-promises / functional-promises / tests / errors.js View on Github external
const test = require('ava').default
const FP = require('../')
// const FP = require('../index.d.ts')
const chalk = require('chalk').default

/// 

test('Can FP.quiet() Error', t => {
  t.plan(1)
  return FP.resolve([1, 2, 3, 4])
    .quiet(42)
    .map((n) => {
      if (n === 4) {
        return Promise.reject(new TypeError('#4 found, dummy error!'))
      }
      return n
    })
    .then((results) => {
      t.truthy(results[3] instanceof TypeError)
    })
    .catch(err => {
      console.warn(chalk.yellowBright`ERR:`, err.message)
      t.fail('shouldnt get here')
    })
github richardeschloss / nuxt-socket-io / test / e2e / nuxtSocket.js View on Github external
/* eslint-disable no-console */
import { serial as test } from 'ava'
import ioClient from 'socket.io-client'
import { ioServerInit, nuxtInit, nuxtClose } from '../utils'

test.before(ioServerInit)

test.before(nuxtInit)

test.after('Closing server and nuxt.js', nuxtClose)

test('Socket io client can connect', (t) => {
  t.timeout(60000)
  return new Promise((resolve) => {
    console.log('attempting to connect')
    const socket = ioClient('http://localhost:4000')
    socket.on('connect', () => {
      console.log('client connected!!', socket.id)
      t.truthy(socket.id)
      resolve()
    })
  })
})
github richardeschloss / nuxt-socket-io / test / e2e / nuxtSocket.js View on Github external
/* eslint-disable no-console */
import { serial as test } from 'ava'
import ioClient from 'socket.io-client'
import { ioServerInit, nuxtInit, nuxtClose } from '../utils'

test.before(ioServerInit)

test.before(nuxtInit)

test.after('Closing server and nuxt.js', nuxtClose)

test('Socket io client can connect', (t) => {
  t.timeout(60000)
  return new Promise((resolve) => {
    console.log('attempting to connect')
    const socket = ioClient('http://localhost:4000')
    socket.on('connect', () => {
      console.log('client connected!!', socket.id)
      t.truthy(socket.id)
      resolve()
    })
  })
github pagarme / superbowleto / test / unit / resources / boleto / model.js View on Github external
company_name: 'Some Company',
    company_document_number: '98154524872',
    company_address: {
      zipcode: '04547006',
      street_number: '1609',
      street: 'Rua Gomes de Carvalho',
      neighborhood: 'Vila Olimpia',
      city: 'São Paulo',
      state: 'SP',
    },
    created_at: now,
    updated_at: now,
  }, 'should be a boleto object')
})

test('generateBoletoCode', (t) => {
  const input = {
    issuer: 'bradesco',
    amount: 2000,
    issuer_account: '9721',
    issuer_agency: '3381',
    issuer_wallet: '26',
    title_id: '1',
    expiration_date: new Date('2017-05-26'),
  }

  const { barcode, digitable_line } = generateBoletoCode(input) // eslint-disable-line

  t.is(barcode, '23792717100000020003381260000000000100097210')
  t.is(digitable_line, '23793.38128 60000.000004 01000.972107 2 71710000002000')
})
github shelljs / shelljs / test / grep.js View on Github external
test.afterEach.always(t => {
  shell.rm('-rf', t.context.tmp);
});


//
// Invalids
//

test('no args', t => {
  const result = shell.grep();
  t.truthy(shell.error());
  t.is(result.code, 2);
});

test('too few args', t => {
  const result = shell.grep(/asdf/g); // too few args
  t.truthy(shell.error());
  t.is(result.code, 2);
});

test('no such file', t => {
  t.falsy(fs.existsSync('/asdfasdf')); // sanity check
  const result = shell.grep(/asdf/g, '/asdfasdf'); // no such file
  t.truthy(shell.error());
  t.is(result.stderr, 'grep: no such file or directory: /asdfasdf');
  t.is(result.code, 2);
});

test('if at least one file is missing, this should be an error', t => {
  t.falsy(fs.existsSync('asdfasdf')); // sanity check
  t.truthy(fs.existsSync(`${t.context.tmp}/file1`)); // sanity check
github zeit / now / test / integration.js View on Github external
binaryPath,
    ['billing', 'rm', 'card_d2j32d9382jr928rd', ...defaultArgs],
    {
      reject: false
    }
  );

  t.is(code, 0);
  t.true(
    stderr.includes(
      `You have no credit cards to choose from to delete under ${contextName}`
    )
  );
});

test('use `-V 1` to deploy a GitHub repository', async t => {
  const { stdout, code } = await execa(
    binaryPath,
    ['-V', 1, '--public', '--name', session, ...defaultArgs, 'leo/hub'],
    {
      reject: false
    }
  );

  // Ensure the exit code is right
  t.is(code, 0);

  // Test if the output is really a URL
  const { href, host } = new URL(stdout);
  t.is(host.split('-')[0], session);

  // Send a test request to the deployment
github ballercat / walt / packages / walt-compiler / src / arc / __tests__ / arc-spec.js View on Github external
import test from 'ava';
import { compile, prettyPrintNode, debug } from '../../';
// import { plugin } from '..';

test('ARC plugin', t => {
  const source = `
  const memory : Memory = { initial: 1 };

  type Node = {
    data: i32,
    left: Node,
    right: Node
  };

  function add(root : Node, data: i32) {
  }

  export function test(): i32 {
    let node : Node = {
      data: 0,
      left: null,
github bdash-app / bdash / test / lib / DataSourceDefinition / Postgres.js View on Github external
import test from 'ava';
import initialize from '../../fixtures/postgres/initialize';
import Postgres from '../../../src/lib/DataSourceDefinition/Postgres';

test.before(async () => {
  await initialize();
});

// TODO: Make it possible to change the config via enviroment variables
let config = {
  host: '127.0.0.1',
  database: 'bdash_test',
};

test('execute', async t => {
  let result = await new Postgres(config).execute('select id, text from test order by id');
  t.deepEqual(result, {
    fields: ['id', 'text'],
    rows: [['1', 'foo'], ['2', 'bar'], ['3', 'baz']],
  });
});
github kub1x / rodnecislo / test / rodnecislo.js View on Github external
import sinon from 'sinon';
import test from 'ava';

import { rodnecislo, RodneCislo } from '../src/lib/rodnecislo';

// Mock new Date()

const NOW_SEC = 1485865800000; // 31.1.2017 13:30

let clock;

test.before(() => {
  clock = sinon.useFakeTimers(NOW_SEC);
});

test.after(() => {
  clock.restore();
});

// Tests

test('constructor returns RodneCislo', (t) => {
  const v = rodnecislo();

  t.truthy(v);
  t.true(v instanceof RodneCislo);
});