Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import test from 'ava';
import createDebug from 'debug';
const debug = createDebug('expect-plugin:test');
import EventEmitter from 'events';
const shelljs = require('shelljs');
const path = require('path');
//
// We only need this when running unit tests. When the plugin actually runs inside
// a recent version of Artillery, the appropriate object is already set up.
//
global.artillery = {
util: {
template: require('artillery/util').template
}
};
test('Basic interface checks', async t => {
const script = {
config: {},
scenarios: []
};
const ExpectationsPlugin = require('../index');
const events = new EventEmitter();
const plugin = new ExpectationsPlugin.Plugin(script, events);
t.true(typeof ExpectationsPlugin.Plugin === 'function');
t.true(typeof plugin === 'object');
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';
const debug = require('debug')('plugin:expect');
const chalk = require('chalk');
const template = global.artillery ? global.artillery.util.template : require('artillery/util').template;
const _ = require('lodash');
module.exports = {
contentType: expectContentType,
statusCode: expectStatusCode,
hasProperty: expectHasProperty,
equals: expectEquals
};
function expectEquals(expectation, body, req, res, userContext) {
debug('check equals');
debug('expectation:', expectation);
debug('body:', typeof body);
let result = {
ok: false,