How to use codeceptjs - 10 common examples

To help you get started, we’ve selected a few codeceptjs 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 esaude / esaude-emr-poc / test / e2eTests / hooks.js View on Github external
module.exports = function() {
  /** After each test clean up data that was injected into the database */
  event.dispatcher.on(event.test.after, async (test) => {
  	try{
  		// Remove any and all data that was injected into the DB
	  	// after each test
	  	await Apis.cleanUp();
  	} catch (err) {
        // eslint-disable-next-line angular/log
  		console.log(`The following error was thrown while cleaning up injected data: ${err}`);
  	}
  });
};
github LiskHQ / lisk-core / test / stress / 1_diversified.js View on Github external
const output = require('codeceptjs').output;
const utils = require('../../utils');

const I = actor();
const count = Math.ceil(utils.TRS_POOL_LIMIT / 13); // T:2, SPP: 1, D 2, V: 2, UV: 2, M: 2, Dapp: 2 = 13 types of transactions
let all_trxs = {};

const accounts = utils.createAccounts(count);
const accounts_with_spp = utils.createAccounts(count);

const getAllTransactions = () => {
	const transactions = Object.keys(all_trxs).map(transaction_type => {
		const trxs = all_trxs[transaction_type];
		if (!transaction_type.match('_signatures')) {
			return trxs;
		}
		return [];
github esaude / esaude-emr-poc / test / e2eTests / hooks.js View on Github external
const event = require('codeceptjs').event;
const Apis = require('./rest/openMrsApis');

/**
 * Attaches handlers to Codeceptjs events.
 * All high level event handlers should be attached in this file.
 * Right now this function listens for when a test has completed
 * and cleans up any data that was injected into the database
 * during the test.
 */
module.exports = function() {
  /** After each test clean up data that was injected into the database */
  event.dispatcher.on(event.test.after, async (test) => {
  	try{
  		// Remove any and all data that was injected into the DB
	  	// after each test
	  	await Apis.cleanUp();
github LiskHQ / lisk-core / qa / support / lisk_util.js View on Github external
async waitUntilBlock(expectedHeight, counter) {
		const {
			data: { height },
		} = await this.call().getNodeStatus();
		const pendingTrxCnt = await this.getPendingTransactionCount();

		counter = counter ? (counter += 1) : 1;

		output.print(
			`Counter: ${counter}, Timestamp: ${new Date().toISOString()}, current height: ${height}, expected height: ${expectedHeight}, pending trxs: ${pendingTrxCnt}`
		);

		if (counter >= 20) {
			return true;
		}

		if (height >= expectedHeight) {
			// Remove the buffer time when network is stable
			if (pendingTrxCnt >= 0) {
				await this.wait(BLOCK_TIME);
			}
			return height;
		}

		await this.wait(BLOCK_TIME);
github LiskHQ / lisk-core / qa / support / lisk_util.js View on Github external
const chai = require('chai');
const elements = require('lisk-elements');
const output = require('codeceptjs').output;
const API = require('./api.js');
const {
	config,
	GENESIS_ACCOUNT,
	ASGARD_FIXTURE,
	seedNode,
	networkIdentifier,
} = require('../fixtures');
const { TO_BEDDOWS, BLOCK_TIME, from } = require('../utils');

const users = {};
chai.config.truncateThreshold = 0;

/* eslint camelcase: ["error", {allow: ["codecept_helper"]}] */
const Helper = codecept_helper;
github LiskHQ / lisk-core / qa / support / validate_helper.js View on Github external
const output = require('codeceptjs').output;
const chai = require('chai');
const apiSchema = require('../api_schema');
const { TO_LISK, TO_BEDDOWS, from, sortBy, flattern } = require('../utils');
const LiskUtil = require('./lisk_util');

/* eslint camelcase: ["error", {allow: ["codecept_helper"]}] */
const Helper = codecept_helper;
const liskUtil = new LiskUtil();

chai.use(require('chai-json-schema'));
chai.use(require('chai-sorted'));
chai.use(require('chai-bignumber')());

const expect = chai.expect;
const otherFields = [
	'username',
github LiskHQ / lisk-core / test / tools / network.js View on Github external
const splitDelegatesByPeers = (delegates, peers) => {
	if (peers.length === 0) {
		output.print(
			'\n',
			'***********Please run npm run tools:peers:config to generate peer list*************',
			'\n'
		);
		process.exit(1);
	}

	if (peers.length > 101) {
		peers.splice(101);
	}

	const chunkSize = Math.ceil(delegates.length / peers.length);
	const delegateList = chunkArray(delegates, chunkSize);
	return delegateList;
};
github LiskHQ / lisk-core / test / tools / network.js View on Github external
Scenario('List peers', async () => {
	try {
		const allPeers = await I.getAllPeers(100, 0);
		output.print('Peers config list: ', JSON.stringify(allPeers, null, '\t'));
	} catch (error) {
		output.print('Failed to get peers list: ');
		output.error(error);
		process.exit(1);
	}
})
	.tag('@peers_list');
github LiskHQ / lisk-core / qa / support / validate_helper.js View on Github external
expectVotersResultToMatchParams(response, params) {
		try {
			Object.entries(params).forEach(item => {
				const [k, v] = item;
				if (['sort'].includes(k)) {
					const [field, order] = v.split(':');
					this.expectResponseToBeSortedBy(response.data.voters, field, order);
				} else if (k !== 'limit') {
					expect(response.data[k].toString()).to.deep.equal(v);
				}
			});
		} catch (error) {
			output.error(error);
		}
	}
github LiskHQ / lisk-core / qa / support / validate_helper.js View on Github external
expectVotesResultToMatchParams(response, params) {
		try {
			Object.entries(params).forEach(item => {
				const [k, v] = item;
				if (['sort'].includes(k)) {
					const [field, order] = v.split(':');
					this.expectResponseToBeSortedBy(response.data.votes, field, order);
				} else if (k !== 'limit') {
					expect(response.data[k].toString()).to.deep.equal(v);
				}
			});
		} catch (error) {
			output.error(error);
		}
	}

codeceptjs

Supercharged End 2 End Testing Framework for NodeJS

MIT
Latest version published 18 hours ago

Package Health Score

92 / 100
Full package analysis