Best JavaScript code snippet using ava
test-rules.js
Source:test-rules.js
1'use strict';2const test = require('ava');3const request = require('supertest');4const cloneDeep = require('lodash.clonedeep');5const aws = require('@cumulus/common/aws');6const { randomString } = require('@cumulus/common/test-utils');7const bootstrap = require('../../../lambdas/bootstrap');8const models = require('../../../models');9const {10 createFakeJwtAuthToken11} = require('../../../lib/testUtils');12const { Search } = require('../../../es/search');13const assertions = require('../../../lib/assertions');14const esIndex = randomString();15process.env.AccessTokensTable = randomString();16process.env.RulesTable = randomString();17process.env.UsersTable = randomString();18process.env.stackName = randomString();19process.env.system_bucket = randomString();20process.env.TOKEN_SECRET = randomString();21// import the express app after setting the env variables22const { app } = require('../../../app');23const workflowName = randomString();24const workflowfile = `${process.env.stackName}/workflows/${workflowName}.json`;25const testRule = {26 name: 'make_coffee',27 workflow: workflowName,28 provider: 'whole-foods',29 collection: {30 name: 'compass',31 version: '0.0.0'32 },33 rule: {34 type: 'onetime'35 },36 state: 'DISABLED'37};38let jwtAuthToken;39let accessTokenModel;40let ruleModel;41let userModel;42test.before(async () => {43 await bootstrap.bootstrapElasticSearch('fakehost', esIndex);44 await aws.s3().createBucket({ Bucket: process.env.system_bucket }).promise();45 await aws.s3().putObject({46 Bucket: process.env.system_bucket,47 Key: workflowfile,48 Body: 'test data'49 }).promise();50 ruleModel = new models.Rule();51 await ruleModel.createTable();52 await ruleModel.create(testRule);53 userModel = new models.User();54 await userModel.createTable();55 accessTokenModel = new models.AccessToken();56 await accessTokenModel.createTable();57 jwtAuthToken = await createFakeJwtAuthToken({ accessTokenModel, userModel });58});59test.after.always(async () => {60 await accessTokenModel.deleteTable();61 await ruleModel.deleteTable();62 await userModel.deleteTable();63 await aws.recursivelyDeleteS3Bucket(process.env.system_bucket);64 const esClient = await Search.es('fakehost');65 await esClient.indices.delete({ index: esIndex });66});67test('CUMULUS-911 GET without pathParameters and without an Authorization header returns an Authorization Missing response', async (t) => {68 const response = await request(app)69 .get('/rules')70 .set('Accept', 'application/json')71 .expect(401);72 assertions.isAuthorizationMissingResponse(t, response);73});74test('CUMULUS-911 GET with pathParameters and without an Authorization header returns an Authorization Missing response', async (t) => {75 const response = await request(app)76 .get('/rules/asdf')77 .set('Accept', 'application/json')78 .expect(401);79 assertions.isAuthorizationMissingResponse(t, response);80});81test('CUMULUS-911 POST with pathParameters and without an Authorization header returns an Authorization Missing response', async (t) => {82 const response = await request(app)83 .post('/rules/asdf')84 .set('Accept', 'application/json')85 .expect(401);86 assertions.isAuthorizationMissingResponse(t, response);87});88test('CUMULUS-911 PUT with pathParameters and without an Authorization header returns an Authorization Missing response', async (t) => {89 const response = await request(app)90 .put('/rules/asdf')91 .set('Accept', 'application/json')92 .expect(401);93 assertions.isAuthorizationMissingResponse(t, response);94});95test('CUMULUS-911 DELETE with pathParameters and without an Authorization header returns an Authorization Missing response', async (t) => {96 const response = await request(app)97 .delete('/rules/asdf')98 .set('Accept', 'application/json')99 .expect(401);100 assertions.isAuthorizationMissingResponse(t, response);101});102test('CUMULUS-912 GET without pathParameters and with an invalid access token returns an unauthorized response', async (t) => {103 const response = await request(app)104 .get('/rules')105 .set('Accept', 'application/json')106 .set('Authorization', 'Bearer ThisIsAnInvalidAuthorizationToken')107 .expect(403);108 assertions.isInvalidAccessTokenResponse(t, response);109});110test('CUMULUS-912 GET with pathParameters and with an invalid access token returns an unauthorized response', async (t) => {111 const response = await request(app)112 .get('/rules/asdf')113 .set('Accept', 'application/json')114 .set('Authorization', 'Bearer ThisIsAnInvalidAuthorizationToken')115 .expect(403);116 assertions.isInvalidAccessTokenResponse(t, response);117});118test.todo('CUMULUS-912 GET with an unauthorized user returns an unauthorized response');119test('CUMULUS-912 POST with pathParameters and with an invalid access token returns an unauthorized response', async (t) => {120 const response = await request(app)121 .post('/rules/asdf')122 .set('Accept', 'application/json')123 .set('Authorization', 'Bearer ThisIsAnInvalidAuthorizationToken')124 .expect(403);125 assertions.isInvalidAccessTokenResponse(t, response);126});127test.todo('CUMULUS-912 POST with pathParameters and with an unauthorized user returns an unauthorized response');128test('CUMULUS-912 PUT with pathParameters and with an invalid access token returns an unauthorized response', async (t) => {129 const response = await request(app)130 .put('/rules/asdf')131 .set('Accept', 'application/json')132 .set('Authorization', 'Bearer ThisIsAnInvalidAuthorizationToken')133 .expect(403);134 assertions.isInvalidAccessTokenResponse(t, response);135});136test.todo('CUMULUS-912 PUT with pathParameters and with an unauthorized user returns an unauthorized response');137test('CUMULUS-912 DELETE with pathParameters and with an invalid access token returns an unauthorized response', async (t) => {138 const response = await request(app)139 .delete('/rules/asdf')140 .set('Accept', 'application/json')141 .set('Authorization', 'Bearer ThisIsAnInvalidAuthorizationToken')142 .expect(403);143 assertions.isInvalidAccessTokenResponse(t, response);144});145test.todo('CUMULUS-912 DELETE with pathParameters and with an unauthorized user returns an unauthorized response');146// TODO(aimee): Add a rule to ES. List uses ES and we don't have any rules in ES.147test('default returns list of rules', async (t) => {148 const response = await request(app)149 .get('/rules')150 .set('Accept', 'application/json')151 .set('Authorization', `Bearer ${jwtAuthToken}`)152 .expect(200);153 const { results } = response.body;154 t.is(results.length, 0);155});156test('GET gets a rule', async (t) => {157 const response = await request(app)158 .get(`/rules/${testRule.name}`)159 .set('Accept', 'application/json')160 .set('Authorization', `Bearer ${jwtAuthToken}`)161 .expect(200);162 const { name } = response.body;163 t.is(name, testRule.name);164});165test('When calling the API endpoint to delete an existing rule it does not return the deleted rule', async (t) => {166 const newRule = Object.assign({}, testRule, { name: 'pop_culture_reference' });167 let response = await request(app)168 .post('/rules')169 .set('Accept', 'application/json')170 .set('Authorization', `Bearer ${jwtAuthToken}`)171 .send(newRule)172 .expect(200);173 t.is(response.body.message, 'Record saved');174 response = await request(app)175 .delete(`/rules/${newRule.name}`)176 .set('Accept', 'application/json')177 .set('Authorization', `Bearer ${jwtAuthToken}`)178 .expect(200);179 const { message, record } = response.body;180 t.is(message, 'Record deleted');181 t.is(record, undefined);182});183test('403 error when calling the API endpoint to delete an existing rule without an valid access token', async (t) => {184 const newRule = Object.assign({}, testRule, { name: 'side_step_left' });185 let response = await request(app)186 .post('/rules')187 .set('Accept', 'application/json')188 .set('Authorization', `Bearer ${jwtAuthToken}`)189 .send(newRule)190 .expect(200);191 const { message, record } = response.body;192 t.is(message, 'Record saved');193 newRule.createdAt = record.createdAt;194 newRule.updatedAt = record.updatedAt;195 response = await request(app)196 .delete(`/rules/${newRule.name}`)197 .set('Accept', 'application/json')198 .set('Authorization', 'Bearer ThisIsAnInvalidAuthorizationToken')199 .expect(403);200 assertions.isInvalidAccessTokenResponse(t, response);201 response = await request(app)202 .get(`/rules/${newRule.name}`)203 .set('Accept', 'application/json')204 .set('Authorization', `Bearer ${jwtAuthToken}`)205 .expect(200);206 t.deepEqual(response.body, record);207});208test('POST creates a rule', async (t) => {209 const newRule = Object.assign(cloneDeep(testRule), { name: 'make_waffles' });210 const response = await request(app)211 .post('/rules')212 .set('Accept', 'application/json')213 .set('Authorization', `Bearer ${jwtAuthToken}`)214 .send(newRule)215 .expect(200);216 const { message, record } = response.body;217 t.is(message, 'Record saved');218 newRule.createdAt = record.createdAt;219 newRule.updatedAt = record.updatedAt;220 t.deepEqual(record, newRule);221});222test('POST returns a record exists when one exists', async (t) => {223 const newRule = Object.assign({}, testRule);224 const response = await request(app)225 .post('/rules')226 .set('Accept', 'application/json')227 .set('Authorization', `Bearer ${jwtAuthToken}`)228 .send(newRule)229 .expect(409);230 const { message, record } = response.body;231 t.is(message, `A record already exists for ${newRule.name}`);232 t.falsy(record);233});234test('PUT updates a rule', async (t) => {235 const newRule = Object.assign({}, testRule, { state: 'ENABLED' });236 const response = await request(app)237 .put(`/rules/${testRule.name}`)238 .set('Accept', 'application/json')239 .set('Authorization', `Bearer ${jwtAuthToken}`)240 .send({ state: 'ENABLED' })241 .expect(200);242 const record = response.body;243 newRule.createdAt = record.createdAt;244 newRule.updatedAt = record.updatedAt;245 t.deepEqual(record, newRule);246});247test('PUT returns "record does not exist"', async (t) => {248 const response = await request(app)249 .put('/rules/new_make_coffee')250 .set('Accept', 'application/json')251 .set('Authorization', `Bearer ${jwtAuthToken}`)252 .send({ state: 'ENABLED' })253 .expect(404);254 const { message, record } = response.body;255 t.is(message, 'Record does not exist');256 t.falsy(record);257});258test('DELETE deletes a rule', async (t) => {259 const response = await request(app)260 .delete(`/rules/${testRule.name}`)261 .set('Accept', 'application/json')262 .set('Authorization', `Bearer ${jwtAuthToken}`)263 .expect(200);264 const { message } = response.body;265 t.is(message, 'Record deleted');...
stats.js
Source:stats.js
1'use strict';2const test = require('ava');3const request = require('supertest');4const { randomString } = require('@cumulus/common/test-utils');5const models = require('../../models');6const assertions = require('../../lib/assertions');7process.env.AccessTokensTable = randomString();8process.env.UsersTable = randomString();9// import the express app after setting the env variables10const { app } = require('../../app');11let userModel;12test.before(async () => {13 userModel = new models.User();14 await userModel.createTable();15});16test.after.always(() => userModel.deleteTable());17test('CUMULUS-911 GET without pathParameters and without an Authorization header returns an Authorization Missing response', async (t) => {18 const response = await request(app)19 .get('/stats')20 .set('Accept', 'application/json')21 .expect(401);22 assertions.isAuthorizationMissingResponse(t, response);23});24test('CUMULUS-911 GET /stats/histogram without an Authorization header returns an Authorization Missing response', async (t) => {25 const response = await request(app)26 .get('/stats/histogram')27 .set('Accept', 'application/json')28 .expect(401);29 assertions.isAuthorizationMissingResponse(t, response);30});31test('CUMULUS-911 GET /stats/aggregate without an Authorization header returns an Authorization Missing response', async (t) => {32 const response = await request(app)33 .get('/stats/aggregate')34 .set('Accept', 'application/json')35 .expect(401);36 assertions.isAuthorizationMissingResponse(t, response);37});38test('CUMULUS-911 GET /stats/average without an Authorization header returns an Authorization Missing response', async (t) => {39 const response = await request(app)40 .get('/stats/average')41 .set('Accept', 'application/json')42 .expect(401);43 assertions.isAuthorizationMissingResponse(t, response);44});45test('CUMULUS-912 GET without pathParameters and with an invalid access token returns an unauthorized response', async (t) => {46 const response = await request(app)47 .get('/stats/')48 .set('Accept', 'application/json')49 .set('Authorization', 'Bearer ThisIsAnInvalidAuthorizationToken')50 .expect(403);51 assertions.isInvalidAccessTokenResponse(t, response);52});53test.todo('CUMULUS-912 GET without pathParameters and with an unauthorized user returns an unauthorized response');54test('CUMULUS-912 GET /stats/histogram with an unauthorized user returns an unauthorized response', async (t) => {55 const response = await request(app)56 .get('/stats/histogram')57 .set('Accept', 'application/json')58 .set('Authorization', 'Bearer ThisIsAnInvalidAuthorizationToken')59 .expect(403);60 assertions.isInvalidAccessTokenResponse(t, response);61});62test('CUMULUS-912 GET /stats/aggregate with an invalid access token returns an unauthorized response', async (t) => {63 const response = await request(app)64 .get('/stats/aggregate')65 .set('Accept', 'application/json')66 .set('Authorization', 'Bearer ThisIsAnInvalidAuthorizationToken')67 .expect(403);68 assertions.isInvalidAccessTokenResponse(t, response);69});70test('CUMULUS-912 GET /stats/average with an invalid access token returns an unauthorized response', async (t) => {71 const response = await request(app)72 .get('/stats/average')73 .set('Accept', 'application/json')74 .set('Authorization', 'Bearer ThisIsAnInvalidAuthorizationToken')75 .expect(403);76 assertions.isInvalidAccessTokenResponse(t, response);...
hypothesis.js
Source:hypothesis.js
1const testing = require('../index')2const {expect} = require('chai')3const sinon = require('sinon')4const testCases = {}5const assertions = {}6assertions.isValidHypothesisSuccess = (assertionSpy, results) => {7 expect(assertionSpy.callCount).to.equal(1, 'test not called.')8 expect(assertionSpy.callCount).to.equal(1, 'test not called.')9 expect(results.hypothesis).to.be.a('string')10 expect(results.conditions).to.be.an('array')11 expect(results.results).to.be.an('array')12 expect(results.type).to.equal('hypothesis-result-set')13}14assertions.isValidHypothesisFailure = (assertionSpy, results) => {15 expect(assertionSpy.callCount).to.equal(1, 'test not called.')16 expect(results.hypothesis).to.be.a('string')17 expect(results.conditions).to.be.an('array')18 expect(results.results).to.be.an('array')19 expect(results.type).to.equal('hypothesis-result-set')20}21testCases.hypothesis = async () => {22 await testCases.hypothesis.success()23 await testCases.hypothesis.failure()24}25testCases.hypothesis.success = async () => {26 console.log('testing.hypothesis.success')27 const generator = function * () {28 yield [1, 2, 3]29 }30 const assertion = (a, b, c) => {31 expect(a).to.equal(1)32 expect(b).to.equal(2)33 expect(c).to.equal(3)34 }35 const assertionSpy = sinon.spy(assertion)36 const results = await testing.hypothesis('testing.hypothesis')37 .cases(generator)38 .always(assertionSpy)39 .run()40 assertions.isValidHypothesisSuccess(assertionSpy, results)41}42testCases.hypothesis.failure = async () => {43 console.log('testing.hypothesis.failure')44 const generator = function * () {45 yield [1, 2, 3]46 }47 const assertion = (a, b, c) => {48 expect(a).to.equal(1)49 expect(b).to.equal(2)50 expect(c).to.equal(3)51 }52 const assertionSpy = sinon.spy(assertion)53 const results = testing.hypothesis('testing.hypothesis')54 .cases(generator)55 .always(assertionSpy)56 .run()57 assertions.isValidHypothesisFailure(assertionSpy, results)58}...
Using AI Code Generation
1import test from 'ava';2import * as assertions from 'ava-assertions';3test('is', t => {4 t.is(assertions.is(true, true), true);5 t.is(assertions.is(false, false), true);6 t.is(assertions.is(1, 1), true);7 t.is(assertions.is(1, 2), false);8 t.is(assertions.is('foo', 'foo'), true);9 t.is(assertions.is('foo', 'bar'), false);10 t.is(assertions.is(null, null), true);11 t.is(assertions.is(undefined, undefined), true);12 t.is(assertions.is({}, {}), false);13 t.is(assertions.is([], []), false);14 t.is(assertions.is(/a/, /a/), false);15 t.is(assertions.is(new Date(), new Date()), false);16 t.is(assertions.is(function () {}, function () {}), false);17 t.is(assertions.is(function () {}, function () {}), false);18 t.is(assertions.is({a: 1}, {a: 1}), false);19 t.is(assertions.is([1, 2, 3], [1, 2, 3]), false);20 t.is(assertions.is({a: {b: {c: 1}}}, {a: {b: {c: 1}}}), false);21 t.is(assertions.is({a: {b: {c: 1}}}, {a: {b: {c: 2}}}), false);22 t.is(assertions.is({a: {b: {c: 1}}}, {a: {b: {d: 1}}}), false);23 t.is(assertions.is({a: {b: {c: 1}}}, {a: {b: {}}}), false);24 t.is(assertions.is({a: {b: {c: 1}}}, {a: {}}), false);25 t.is(assertions.is({a: {b: {c: 1}}}, {}), false);26 t.is(assertions.is({a: 1}, {a: 1, b: 2}), false);27 t.is(assertions.is({a: 1, b: 2}, {a: 1}), false);28 t.is(assertions.is([1, 2
Using AI Code Generation
1const test = require('ava');2const {is} = require('ava/lib/assert');3test('is', t => {4 t.is(is(1, 1), true);5 t.is(is(1, '1'), false);6});7const test = require('ava');8const {deepEqual} = require('ava/lib/assert');9test('deepEqual', t => {10 t.is(deepEqual(1, 1), true);11 t.is(deepEqual(1, '1'), false);12});13const test = require('ava');14const {notDeepEqual} = require('ava/lib/assert');15test('notDeepEqual', t => {16 t.is(notDeepEqual(1, 1), false);17 t.is(notDeepEqual(1, '1'), true);18});19const test = require('ava');20const {notDeepEqual} = require('ava/lib/assert');21test('notDeepEqual', t => {22 t.is(notDeepEqual(1, 1), false);23 t.is(notDeepEqual(1, '1'), true);24});25const test = require('ava');26const {true} = require('ava/lib/assert');27test('true', t => {28 t.is(true(true), true);29 t.is(true(false), false);30});31const test = require('ava');32const {false} = require('ava/lib/assert');33test('false', t => {34 t.is(false(false), true);35 t.is(false(true), false);36});37const test = require('ava');38const {truthy} = require('ava/lib/assert');39test('truthy', t => {40 t.is(truthy(true), true);41 t.is(truthy(false), false);42});43const test = require('ava');44const {falsy} = require('ava/lib/assert');45test('falsy', t => {46 t.is(falsy(false), true);47 t.is(falsy(true), false);48});49const test = require('ava');50const {regex} =
Using AI Code Generation
1import test from 'ava';2import { is } from 'ava';3test('is', t => {4 t.is(1, 1);5 t.is(1, 1.0);6 t.is(1, '1');7 t.is(true, 1);8 t.is(false, 0);9 t.is(true, '1');10 t.is(false, '0');11 t.is('foo', 'foo');12 t.is('foo', 'bar');13 t.is([1, 2], [1, 2]);14 t.is({a: 1}, {a: 1});15 t.is('foo', ['foo']);16 t.is('bar', ['bar']);
Using AI Code Generation
1const test = require('ava');2const {is} = require('ava/lib/assert');3test('is', t => {4 is('foo', 'foo');5 t.pass();6});7const test = require('ava');8test('is', t => {9 t.is('foo', 'foo');10 t.pass();11});12const test = require('ava');13const {is} = require('ava/lib/assert');14test('is', t => {15 is('foo', 'foo');16 t.pass();17});18test('is', t => {19 t.is('foo', 'foo');20 t.pass();21});22const assert = require('assert');23describe('is', () => {24 it('should compare two values', () => {25 assert.equal('foo', 'foo');26 });27});28const assert = require('assert');29describe('is', () => {30 it('should compare two values', () => {31 assert.equal('foo', 'foo');32 });33});34const assert = require('assert');35describe('is', () => {36 it('should compare two values', () => {37 assert.equal('foo', 'foo');38 });39});
Using AI Code Generation
1const test = require('ava');2const assertions = require('assertions');3test('is', t => {4 t.plan(1);5 t.is(assertions.is('string', 'string'), true);6});7test('isNot', t => {8 t.plan(1);9 t.is(assertions.isNot('string', 'string'), false);10});11test('isTrue', t => {12 t.plan(1);13 t.is(assertions.isTrue(true), true);14});15test('isFalse', t => {16 t.plan(1);17 t.is(assertions.isFalse(false), true);18});19test('isNull', t => {20 t.plan(1);21 t.is(assertions.isNull(null), true);22});23test('isNotNull', t => {24 t.plan(1);25 t.is(assertions.isNotNull(''), true);26});27test('isUndefined', t => {28 t.plan(1);29 t.is(assertions.isUndefined(), true);30});31test('isDefined', t => {32 t.plan(1);33 t.is(assertions.isDefined(0), true);34});35test('isFunction', t => {36 t.plan(1);37 t.is(assertions.isFunction(function() {}), true);38});39test('isNotFunction', t => {40 t.plan(1);41 t.is(assertions.isNotFunction(''), true);42});43test('isObject', t => {44 t.plan(1);45 t.is(assertions.isObject({}), true);46});47test('isNotObject', t => {48 t.plan(1);49 t.is(assertions.isNotObject(''), true);50});51test('isArray', t => {52 t.plan(1);53 t.is(assertions.isArray([]), true);54});55test('isNotArray', t => {56 t.plan(1);57 t.is(assertions.isNotArray(''), true);58});59test('isString', t => {60 t.plan(1);61 t.is(assertions.isString(''), true);62});63test('isNotString', t => {64 t.plan(1);65 t.is(assertions.isNotString(0), true);66});67test('isNumber', t => {68 t.plan(1);69 t.is(assertions.isNumber(0), true);70});71test('isNotNumber', t => {72 t.plan(1);73 t.is(assertions.isNotNumber(''), true);74});75test('is
Using AI Code Generation
1import test from 'ava';2import assertions from 'ava-assertions';3test('assertions.is', t => {4 t.is(assertions.is(1, 1), true)5});6test('assertions.is', t => {7 t.is(assertions.is(1, 2), false)8});9test('assertions.is', t => {10 t.is(assertions.is(1, '1'), false)11});12test('assertions.is', t => {13 t.is(assertions.is('1', '1'), true)14});15test('assertions.is', t => {16 t.is(assertions.is('1', 1), false)17});18test('assertions.is', t => {19 t.is(assertions.is('1', '2'), false)20});21test('assertions.is', t => {22 t.is(assertions.is(1, 1, 'strictly'), true)23});24test('assertions.is', t => {25 t.is(assertions.is(1, 2, 'strictly'), false)26});27test('assertions.is', t => {28 t.is(assertions.is(1, '1', 'strictly'), false)29});30test('assertions.is', t => {31 t.is(assertions.is('1', '1', 'strictly'), true)32});33test('assertions.is', t => {34 t.is(assertions.is('1', 1, 'strictly'), false)35});36test('assertions.is', t => {37 t.is(assertions.is('1', '2', 'strictly'), false)38});39test('assertions.is', t => {40 t.is(assertions.is(1, 1, 'loosely'), true)41});42test('assertions.is', t => {43 t.is(assertions.is(1, 2, 'loosely'), false)44});45test('assertions.is', t => {46 t.is(assertions.is(1, '1', 'loosely'), true)47});48test('assertions.is', t => {49 t.is(assert
Using AI Code Generation
1const test = require('ava');2const is = require('assertions.is');3const fs = require('fs-extra');4const path = require('path');5const run = require('./run');6const runCli = require('./run-cli');7test('run', async t => {8 t.plan(1);9 const result = await run('test.js');10 t.is(result, 'test');11});12test('runCli', async t => {13 t.plan(1);14 const result = await runCli('test.js');15 t.is(result, 'test');16});17test('runCli with args', async t => {18 t.plan(1);19 const result = await runCli('test.js', ['--foo', 'bar']);20 t.is(result, 'test --foo bar');21});22test('runCli with stdin', async t => {23 t.plan(1);24 const result = await runCli('test.js', {input: 'foo'});25 t.is(result, 'test foo');26});27test('runCli with stdin and args', async t => {28 t.plan(1);29 const result = await runCli('test.js', ['--foo', 'bar'], {input: 'foo'});30 t.is(result, 'test --foo bar foo');31});32test('runCli with env', async t => {33 t.plan(1);34 const result = await runCli('test-env.js', {env: {foo: 'bar'}});35 t.is(result, 'bar');36});37test('runCli with env and args', async t => {38 t.plan(1);39 const result = await runCli('test-env.js', ['--foo', 'bar'], {env: {foo: 'bar'}});40 t.is(result, 'bar --foo bar');41});42test('runCli with env and stdin', async t => {43 t.plan(1);44 const result = await runCli('test-env.js', {env: {foo: 'bar'}, input: 'foo'});45 t.is(result, 'bar foo');46});47test('runCli with env, args and stdin', async t => {48 t.plan(1);49 const result = await runCli('test-env.js', ['--foo', 'bar'], {env: {foo: 'bar'}, input: 'foo'});50 t.is(result, 'bar --foo bar foo');51});52test('runCli with cwd
Using AI Code Generation
1import test from 'ava';2import {is} from 'ramda';3test('is', t => {4 t.true(is(Number, 1));5 t.false(is(Number, '1'));6 t.false(is(Number, undefined));7 t.false(is(Number, null));8 t.false(is(Number, []));9 t.false(is(Number, {}));10 t.false(is(Number, function(){}));11});12import test from 'ava';13import {is} from 'ramda';14test('is', t => {15 t.true(is(Number, 1));16 t.false(is(Number, '1'));17 t.false(is(Number, undefined));18 t.false(is(Number, null));19 t.false(is(Number, []));20 t.false(is(Number, {}));21 t.false(is(Number, function(){}));22});23import test from 'ava';24import {is} from 'ramda';25test('is', t => {26 t.true(is(Number, 1));27 t.false(is(Number, '1'));28 t.false(is(Number, undefined));29 t.false(is(Number, null));30 t.false(is(Number, []));31 t.false(is(Number, {}));32 t.false(is(Number, function(){}));33});34import test from 'ava';35import {is} from 'ramda';36test('is', t => {37 t.true(is(Number, 1));38 t.false(is(Number, '1'));39 t.false(is(Number, undefined));40 t.false(is(Number, null));41 t.false(is(Number, []));42 t.false(is(Number, {}));43 t.false(is(Number, function(){}));44});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!