How to use execCli method in ava

Best JavaScript code snippet using ava

test.js

Source:test.js Github

copy

Full Screen

...105 it('populates changelog with commits since last tag by default', function () {106 commit('feat: first commit')107 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')108 commit('fix: patch release')109 execCli().code.should.equal(0)110 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')111 content.should.match(/patch release/)112 content.should.not.match(/first commit/)113 })114 it('includes all commits if --first-release is true', function () {115 writePackageJson('1.0.1')116 commit('feat: first commit')117 commit('fix: patch release')118 execCli('--first-release').code.should.equal(0)119 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')120 content.should.match(/patch release/)121 content.should.match(/first commit/)122 shell.exec('git tag').stdout.should.match(/1\.0\.1/)123 })124 it('skipping changelog will not create a changelog file', function () {125 writePackageJson('1.0.0')126 commit('feat: first commit')127 return execCliAsync('--skip.changelog true')128 .then(function () {129 getPackageVersion().should.equal('1.1.0')130 let fileNotFound = false131 try {132 fs.readFileSync('CHANGELOG.md', 'utf-8')133 } catch (err) {134 fileNotFound = true135 }136 fileNotFound.should.equal(true)137 })138 })139 })140 describe('CHANGELOG.md exists', function () {141 it('appends the new release above the last release, removing the old header (legacy format)', function () {142 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')143 commit('feat: first commit')144 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')145 commit('fix: patch release')146 execCli().code.should.equal(0)147 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')148 content.should.match(/1\.0\.1/)149 content.should.not.match(/legacy header format/)150 })151 // TODO: we should use snapshots which are easier to update than large152 // string assertions; we should also consider not using the CLI which153 // is slower than calling standard-version directly.154 it('appends the new release above the last release, removing the old header (new format)', function () {155 // we don't create a package.json, so no {{host}} and {{repo}} tag156 // will be populated, let's use a compareUrlFormat without these.157 const cliArgs = '--compareUrlFormat=/compare/{{previousTag}}...{{currentTag}}'158 commit('feat: first commit')159 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')160 commit('fix: patch release')161 execCli(cliArgs).code.should.equal(0)162 let content = fs.readFileSync('CHANGELOG.md', 'utf-8')163 // remove commit hashes and dates to make testing against a static string easier:164 content = content.replace(/patch release [0-9a-f]{6,8}/g, 'patch release ABCDEFXY').replace(/\([0-9]{4}-[0-9]{2}-[0-9]{2}\)/g, '(YYYY-MM-DD)')165 content.should.equal('# Changelog\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n\n### [1.0.1](/compare/v1.0.0...v1.0.1) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* patch release ABCDEFXY\n')166 commit('fix: another patch release')167 // we've populated no package.json, so no {{host}} and168 execCli(cliArgs).code.should.equal(0)169 content = fs.readFileSync('CHANGELOG.md', 'utf-8')170 content = content.replace(/patch release [0-9a-f]{6,8}/g, 'patch release ABCDEFXY').replace(/\([0-9]{4}-[0-9]{2}-[0-9]{2}\)/g, '(YYYY-MM-DD)')171 content.should.equal('# Changelog\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n\n### [1.0.2](/compare/v1.0.1...v1.0.2) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* another patch release ABCDEFXY\n\n### [1.0.1](/compare/v1.0.0...v1.0.1) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* patch release ABCDEFXY\n')172 })173 it('commits all staged files', function () {174 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')175 commit('feat: first commit')176 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')177 commit('fix: patch release')178 fs.writeFileSync('STUFF.md', 'stuff\n', 'utf-8')179 shell.exec('git add STUFF.md')180 execCli('--commit-all').code.should.equal(0)181 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')182 const status = shell.exec('git status --porcelain') // see http://unix.stackexchange.com/questions/155046/determine-if-git-working-directory-is-clean-from-a-script183 status.should.equal('')184 status.should.not.match(/STUFF.md/)185 content.should.match(/1\.0\.1/)186 content.should.not.match(/legacy header format/)187 })188 it('[DEPRECATED] (--changelogHeader) allows for a custom changelog header', function () {189 fs.writeFileSync('CHANGELOG.md', '', 'utf-8')190 commit('feat: first commit')191 execCli('--changelogHeader="# Pork Chop Log"').code.should.equal(0)192 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')193 content.should.match(/# Pork Chop Log/)194 })195 it('[DEPRECATED] (--changelogHeader) exits with error if changelog header matches last version search regex', function () {196 fs.writeFileSync('CHANGELOG.md', '', 'utf-8')197 commit('feat: first commit')198 execCli('--changelogHeader="## 3.0.2"').code.should.equal(1)199 })200 })201 // TODO: investigate why mock-git does not play well with execFile on Windows.202 if (!isWindows) {203 describe('with mocked git', function () {204 it('--sign signs the commit and tag', function () {205 // mock git with file that writes args to gitcapture.log206 return mockGit('require("fs").appendFileSync("gitcapture.log", JSON.stringify(process.argv.splice(2)) + "\\n")')207 .then(function (unmock) {208 execCli('--sign').code.should.equal(0)209 const captured = shell.cat('gitcapture.log').stdout.split('\n').map(function (line) {210 return line ? JSON.parse(line) : line211 })212 /* eslint-disable no-useless-escape */213 captured[captured.length - 4].should.deep.equal(['commit', '-S', 'CHANGELOG.md', 'package.json', '-m', 'chore(release): 1.0.1'])214 captured[captured.length - 3].should.deep.equal(['tag', '-s', 'v1.0.1', '-m', 'chore(release): 1.0.1'])215 /* eslint-enable no-useless-escape */216 unmock()217 })218 })219 it('exits with error code if git commit fails', function () {220 // mock git by throwing on attempt to commit221 return mockGit('console.error("commit yourself"); process.exit(128);', 'commit')222 .then(function (unmock) {223 const result = execCli()224 result.code.should.equal(1)225 result.stderr.should.match(/commit yourself/)226 unmock()227 })228 })229 it('exits with error code if git add fails', function () {230 // mock git by throwing on attempt to add231 return mockGit('console.error("addition is hard"); process.exit(128);', 'add')232 .then(function (unmock) {233 const result = execCli()234 result.code.should.equal(1)235 result.stderr.should.match(/addition is hard/)236 unmock()237 })238 })239 it('exits with error code if git tag fails', function () {240 // mock git by throwing on attempt to commit241 return mockGit('console.error("tag, you\'re it"); process.exit(128);', 'tag')242 .then(function (unmock) {243 const result = execCli()244 result.code.should.equal(1)245 result.stderr.should.match(/tag, you're it/)246 unmock()247 })248 })249 it('doesn\'t fail fast on stderr output from git', function () {250 // mock git by throwing on attempt to commit251 return mockGit('console.error("haha, kidding, this is just a warning"); process.exit(0);', 'add')252 .then(function (unmock) {253 writePackageJson('1.0.0')254 const result = execCli()255 result.code.should.equal(1)256 result.stderr.should.match(/haha, kidding, this is just a warning/)257 unmock()258 })259 })260 })261 }262 describe('lifecycle scripts', () => {263 describe('prerelease hook', function () {264 it('should run the prerelease hook when provided', function () {265 writePackageJson('1.0.0', {266 'standard-version': {267 scripts: {268 prerelease: 'node scripts/prerelease'269 }270 }271 })272 writeHook('prerelease')273 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')274 commit('feat: first commit')275 const result = execCli('--patch')276 result.code.should.equal(0)277 result.stderr.should.match(/prerelease ran/)278 })279 it('should abort if the hook returns a non-zero exit code', function () {280 writePackageJson('1.0.0', {281 'standard-version': {282 scripts: {283 prerelease: 'node scripts/prerelease && exit 1'284 }285 }286 })287 writeHook('prerelease')288 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')289 commit('feat: first commit')290 const result = execCli('--patch')291 result.code.should.equal(1)292 result.stderr.should.match(/prerelease ran/)293 })294 })295 describe('prebump hook', function () {296 it('should allow prebump hook to return an alternate version #', function () {297 writePackageJson('1.0.0', {298 'standard-version': {299 scripts: {300 prebump: 'node scripts/prebump'301 }302 }303 })304 writeHook('prebump', false, 'console.log("9.9.9")')305 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')306 commit('feat: first commit')307 const result = execCli('--patch')308 result.stdout.should.match(/9\.9\.9/)309 result.code.should.equal(0)310 })311 })312 describe('postbump hook', function () {313 it('should run the postbump hook when provided', function () {314 writePackageJson('1.0.0', {315 'standard-version': {316 scripts: {317 postbump: 'node scripts/postbump'318 }319 }320 })321 writePostBumpHook()322 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')323 commit('feat: first commit')324 const result = execCli('--patch')325 result.code.should.equal(0)326 result.stderr.should.match(/postbump ran/)327 })328 it('should run the postbump and exit with error when postbump fails', function () {329 writePackageJson('1.0.0', {330 'standard-version': {331 scripts: {332 postbump: 'node scripts/postbump'333 }334 }335 })336 writePostBumpHook(true)337 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')338 commit('feat: first commit')339 const result = execCli('--patch')340 result.code.should.equal(1)341 result.stderr.should.match(/postbump-failure/)342 })343 })344 describe('precommit hook', function () {345 it('should run the precommit hook when provided via .versionrc.json (#371)', function () {346 fs.writeFileSync('.versionrc.json', JSON.stringify({347 scripts: {348 precommit: 'node scripts/precommit'349 }350 }), 'utf-8')351 writeHook('precommit')352 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')353 commit('feat: first commit')354 const result = execCli()355 result.code.should.equal(0)356 result.stderr.should.match(/precommit ran/)357 })358 it('should run the precommit hook when provided', function () {359 writePackageJson('1.0.0', {360 'standard-version': {361 scripts: {362 precommit: 'node scripts/precommit'363 }364 }365 })366 writeHook('precommit')367 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')368 commit('feat: first commit')369 const result = execCli('--patch')370 result.code.should.equal(0)371 result.stderr.should.match(/precommit ran/)372 })373 it('should run the precommit hook and exit with error when precommit fails', function () {374 writePackageJson('1.0.0', {375 'standard-version': {376 scripts: {377 precommit: 'node scripts/precommit'378 }379 }380 })381 writeHook('precommit', true)382 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')383 commit('feat: first commit')384 const result = execCli('--patch')385 result.code.should.equal(1)386 result.stderr.should.match(/precommit-failure/)387 })388 it('should allow an alternate commit message to be provided by precommit script', function () {389 writePackageJson('1.0.0', {390 'standard-version': {391 scripts: {392 precommit: 'node scripts/precommit'393 }394 }395 })396 writeHook('precommit', false, 'console.log("releasing %s delivers #222")')397 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')398 commit('feat: first commit')399 const result = execCli('--patch')400 result.code.should.equal(0)401 shell.exec('git log --oneline -n1').should.match(/delivers #222/)402 })403 })404 })405 describe('pre-release', function () {406 it('works fine without specifying a tag id when prereleasing', function () {407 writePackageJson('1.0.0')408 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')409 commit('feat: first commit')410 return execCliAsync('--prerelease')411 .then(function () {412 // it's a feature commit, so it's minor type413 getPackageVersion().should.equal('1.1.0-0')414 })415 })416 it('advises use of --tag prerelease for publishing to npm', function () {417 writePackageJson('1.0.0')418 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')419 commit('feat: first commit')420 execCli('--prerelease').stdout.should.include('--tag prerelease')421 })422 it('advises use of --tag alpha for publishing to npm when tagging alpha', function () {423 writePackageJson('1.0.0')424 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')425 commit('feat: first commit')426 execCli('--prerelease alpha').stdout.should.include('--tag alpha')427 })428 it('does not advise use of --tag prerelease for private modules', function () {429 writePackageJson('1.0.0', { private: true })430 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')431 commit('feat: first commit')432 execCli('--prerelease').stdout.should.not.include('--tag prerelease')433 })434 })435 describe('manual-release', function () {436 it('throws error when not specifying a release type', function () {437 writePackageJson('1.0.0')438 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')439 commit('fix: first commit')440 execCli('--release-as').code.should.above(0)441 })442 describe('release-types', function () {443 const regularTypes = ['major', 'minor', 'patch']444 regularTypes.forEach(function (type) {445 it('creates a ' + type + ' release', function () {446 const originVer = '1.0.0'447 writePackageJson(originVer)448 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')449 commit('fix: first commit')450 return execCliAsync('--release-as ' + type)451 .then(function () {452 const version = {453 major: semver.major(originVer),454 minor: semver.minor(originVer),455 patch: semver.patch(originVer)456 }457 version[type] += 1458 getPackageVersion().should.equal(version.major + '.' + version.minor + '.' + version.patch)459 })460 })461 })462 // this is for pre-releases463 regularTypes.forEach(function (type) {464 it('creates a pre' + type + ' release', function () {465 const originVer = '1.0.0'466 writePackageJson(originVer)467 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')468 commit('fix: first commit')469 return execCliAsync('--release-as ' + type + ' --prerelease ' + type)470 .then(function () {471 const version = {472 major: semver.major(originVer),473 minor: semver.minor(originVer),474 patch: semver.patch(originVer)475 }476 version[type] += 1477 getPackageVersion().should.equal(version.major + '.' + version.minor + '.' + version.patch + '-' + type + '.0')478 })479 })480 })481 })482 describe('release-as-exact', function () {483 it('releases as v100.0.0', function () {484 const originVer = '1.0.0'485 writePackageJson(originVer)486 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')487 commit('fix: first commit')488 return execCliAsync('--release-as v100.0.0')489 .then(function () {490 getPackageVersion().should.equal('100.0.0')491 })492 })493 it('releases as 200.0.0-amazing', function () {494 const originVer = '1.0.0'495 writePackageJson(originVer)496 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')497 commit('fix: first commit')498 return execCliAsync('--release-as 200.0.0-amazing')499 .then(function () {500 getPackageVersion().should.equal('200.0.0-amazing')501 })502 })503 })504 it('creates a prerelease with a new minor version after two prerelease patches', function () {505 writePackageJson('1.0.0')506 fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')507 commit('fix: first patch')508 return execCliAsync('--release-as patch --prerelease dev')509 .then(function () {510 getPackageVersion().should.equal('1.0.1-dev.0')511 })512 // second513 .then(function () {514 commit('fix: second patch')515 return execCliAsync('--prerelease dev')516 })517 .then(function () {518 getPackageVersion().should.equal('1.0.1-dev.1')519 })520 // third521 .then(function () {522 commit('feat: first new feat')523 return execCliAsync('--release-as minor --prerelease dev')524 })525 .then(function () {526 getPackageVersion().should.equal('1.1.0-dev.0')527 })528 .then(function () {529 commit('fix: third patch')530 return execCliAsync('--release-as minor --prerelease dev')531 })532 .then(function () {533 getPackageVersion().should.equal('1.1.0-dev.1')534 })535 .then(function () {536 commit('fix: forth patch')537 return execCliAsync('--prerelease dev')538 })539 .then(function () {540 getPackageVersion().should.equal('1.1.0-dev.2')541 })542 })543 })544 it('handles commit messages longer than 80 characters', function () {545 commit('feat: first commit')546 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')547 commit('fix: this is my fairly long commit message which is testing whether or not we allow for long commit messages')548 execCli().code.should.equal(0)549 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')550 content.should.match(/this is my fairly long commit message which is testing whether or not we allow for long commit messages/)551 })552 it('formats the commit and tag messages appropriately', function () {553 commit('feat: first commit')554 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')555 commit('feat: new feature!')556 execCli().code.should.equal(0)557 // check last commit message558 shell.exec('git log --oneline -n1').stdout.should.match(/chore\(release\): 1\.1\.0/)559 // check annotated tag message560 shell.exec('git tag -l -n1 v1.1.0').stdout.should.match(/chore\(release\): 1\.1\.0/)561 })562 it('appends line feed at end of package.json', function () {563 execCli().code.should.equal(0)564 const pkgJson = fs.readFileSync('package.json', 'utf-8')565 pkgJson.should.equal(['{', ' "version": "1.0.1"', '}', ''].join('\n'))566 })567 it('preserves indentation of tabs in package.json', function () {568 const indentation = '\t'569 const newPkgJson = ['{', indentation + '"version": "1.0.0"', '}', ''].join('\n')570 fs.writeFileSync('package.json', newPkgJson, 'utf-8')571 execCli().code.should.equal(0)572 const pkgJson = fs.readFileSync('package.json', 'utf-8')573 pkgJson.should.equal(['{', indentation + '"version": "1.0.1"', '}', ''].join('\n'))574 })575 it('preserves indentation of spaces in package.json', function () {576 const indentation = ' '577 const newPkgJson = ['{', indentation + '"version": "1.0.0"', '}', ''].join('\n')578 fs.writeFileSync('package.json', newPkgJson, 'utf-8')579 execCli().code.should.equal(0)580 const pkgJson = fs.readFileSync('package.json', 'utf-8')581 pkgJson.should.equal(['{', indentation + '"version": "1.0.1"', '}', ''].join('\n'))582 })583 it('preserves line feed in package.json', function () {584 const newPkgJson = ['{', ' "version": "1.0.0"', '}', ''].join('\n')585 fs.writeFileSync('package.json', newPkgJson, 'utf-8')586 execCli().code.should.equal(0)587 const pkgJson = fs.readFileSync('package.json', 'utf-8')588 pkgJson.should.equal(['{', ' "version": "1.0.1"', '}', ''].join('\n'))589 })590 it('preserves carriage return + line feed in package.json', function () {591 const newPkgJson = ['{', ' "version": "1.0.0"', '}', ''].join('\r\n')592 fs.writeFileSync('package.json', newPkgJson, 'utf-8')593 execCli().code.should.equal(0)594 const pkgJson = fs.readFileSync('package.json', 'utf-8')595 pkgJson.should.equal(['{', ' "version": "1.0.1"', '}', ''].join('\r\n'))596 })597 it('does not run git hooks if the --no-verify flag is passed', function () {598 writeGitPreCommitHook()599 commit('feat: first commit')600 execCli('--no-verify').code.should.equal(0)601 commit('feat: second commit')602 execCli('-n').code.should.equal(0)603 })604 it('does not print output when the --silent flag is passed', function () {605 const result = execCli('--silent')606 result.code.should.equal(0)607 result.stdout.should.equal('')608 result.stderr.should.equal('')609 })610 it('does not display `npm publish` if the package is private', function () {611 writePackageJson('1.0.0', { private: true })612 const result = execCli()613 result.code.should.equal(0)614 result.stdout.should.not.match(/npm publish/)615 })616 it('does not display `all staged files` without the --commit-all flag', function () {617 const result = execCli()618 result.code.should.equal(0)619 result.stdout.should.not.match(/and all staged files/)620 })621 it('does display `all staged files` if the --commit-all flag is passed', function () {622 const result = execCli('--commit-all')623 result.code.should.equal(0)624 result.stdout.should.match(/and all staged files/)625 })626 it('includes merge commits', function () {627 const branchName = 'new-feature'628 commit('feat: first commit')629 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')630 branch(branchName)631 checkout(branchName)632 commit('Implementing new feature')633 checkout('master')634 merge('feat: new feature from branch', branchName)635 execCli().code.should.equal(0)636 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')637 content.should.match(/new feature from branch/)638 const pkgJson = fs.readFileSync('package.json', 'utf-8')639 pkgJson.should.equal(['{', ' "version": "1.1.0"', '}', ''].join('\n'))640 })641 it('exits with error code if "scripts" is not an object', () => {642 writePackageJson('1.0.0', {643 'standard-version': {644 scripts: 'echo hello'645 }646 })647 commit('feat: first commit')648 const result = execCli()649 result.code.should.equal(1)650 result.stderr.should.match(/scripts must be an object/)651 })652 it('exits with error code if "skip" is not an object', () => {653 writePackageJson('1.0.0', {654 'standard-version': {655 skip: true656 }657 })658 commit('feat: first commit')659 const result = execCli()660 result.code.should.equal(1)661 result.stderr.should.match(/skip must be an object/)662 })663})664describe('standard-version', function () {665 beforeEach(initInTempFolder)666 afterEach(finishTemp)667 describe('with mocked conventionalRecommendedBump', function () {668 beforeEach(function () {669 mockery.enable({ warnOnUnregistered: false, useCleanCache: true })670 mockery.registerMock('conventional-recommended-bump', function (_, cb) {671 cb(new Error('bump err'))672 })673 })674 afterEach(function () {675 mockery.deregisterMock('conventional-recommended-bump')676 mockery.disable()677 })678 it('should exit on bump error', function (done) {679 commit('feat: first commit')680 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')681 commit('feat: new feature!')682 require('./index')({ silent: true })683 .catch((err) => {684 err.message.should.match(/bump err/)685 done()686 })687 })688 })689 describe('with mocked conventionalChangelog', function () {690 beforeEach(function () {691 mockery.enable({ warnOnUnregistered: false, useCleanCache: true })692 mockery.registerMock('conventional-changelog', function () {693 const readable = new stream.Readable({ objectMode: true })694 readable._read = function () {695 }696 setImmediate(readable.emit.bind(readable), 'error', new Error('changelog err'))697 return readable698 })699 })700 afterEach(function () {701 mockery.deregisterMock('conventional-changelog')702 mockery.disable()703 })704 it('should exit on changelog error', function (done) {705 commit('feat: first commit')706 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')707 commit('feat: new feature!')708 require('./index')({ silent: true })709 .catch((err) => {710 err.message.should.match(/changelog err/)711 return done()712 })713 })714 })715 it('formats the commit and tag messages appropriately', function (done) {716 commit('feat: first commit')717 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')718 commit('feat: new feature!')719 require('./index')({ silent: true })720 .then(() => {721 // check last commit message722 shell.exec('git log --oneline -n1').stdout.should.match(/chore\(release\): 1\.1\.0/)723 // check annotated tag message724 shell.exec('git tag -l -n1 v1.1.0').stdout.should.match(/chore\(release\): 1\.1\.0/)725 done()726 })727 })728 describe('without a package file to bump', function () {729 it('should exit with error', function () {730 shell.rm('package.json')731 return require('./index')({732 silent: true,733 gitTagFallback: false734 })735 .catch((err) => {736 err.message.should.equal('no package file found')737 })738 })739 })740 describe('bower.json support', function () {741 beforeEach(function () {742 writeBowerJson('1.0.0')743 })744 it('bumps version # in bower.json', function () {745 commit('feat: first commit')746 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')747 commit('feat: new feature!')748 return require('./index')({ silent: true })749 .then(() => {750 JSON.parse(fs.readFileSync('bower.json', 'utf-8')).version.should.equal('1.1.0')751 getPackageVersion().should.equal('1.1.0')752 })753 })754 })755 describe('manifest.json support', function () {756 beforeEach(function () {757 writeManifestJson('1.0.0')758 })759 it('bumps version # in manifest.json', function () {760 commit('feat: first commit')761 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')762 commit('feat: new feature!')763 return require('./index')({ silent: true })764 .then(() => {765 JSON.parse(fs.readFileSync('manifest.json', 'utf-8')).version.should.equal('1.1.0')766 getPackageVersion().should.equal('1.1.0')767 })768 })769 })770 describe('custom `bumpFiles` support', function () {771 it('mix.exs + version.txt', function () {772 // @todo This file path is relative to the `tmp` directory, which is a little confusing773 fs.copyFileSync('../test/mocks/mix.exs', 'mix.exs')774 fs.copyFileSync('../test/mocks/version.txt', 'version.txt')775 fs.copyFileSync('../test/mocks/updater/customer-updater.js', 'custom-updater.js')776 commit('feat: first commit')777 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')778 commit('feat: new feature!')779 return require('./index')({780 silent: true,781 bumpFiles: [782 'version.txt',783 {784 filename: 'mix.exs',785 updater: 'custom-updater.js'786 }787 ]788 })789 .then(() => {790 fs.readFileSync('mix.exs', 'utf-8').should.contain('version: "1.1.0"')791 fs.readFileSync('version.txt', 'utf-8').should.equal('1.1.0')792 })793 })794 it('bumps a custom `plain-text` file', function () {795 fs.copyFileSync('../test/mocks/VERSION-1.0.0.txt', 'VERSION_TRACKER.txt')796 commit('feat: first commit')797 return require('./index')({798 silent: true,799 bumpFiles: [800 {801 filename: 'VERSION_TRACKER.txt',802 type: 'plain-text'803 }804 ]805 })806 .then(() => {807 fs.readFileSync('VERSION_TRACKER.txt', 'utf-8').should.equal('1.1.0')808 })809 })810 })811 describe('custom `packageFiles` support', function () {812 it('reads and writes to a custom `plain-text` file', function () {813 fs.copyFileSync('../test/mocks/VERSION-6.3.1.txt', 'VERSION_TRACKER.txt')814 commit('feat: yet another commit')815 return require('./index')({816 silent: true,817 packageFiles: [818 {819 filename: 'VERSION_TRACKER.txt',820 type: 'plain-text'821 }822 ],823 bumpFiles: [824 {825 filename: 'VERSION_TRACKER.txt',826 type: 'plain-text'827 }828 ]829 })830 .then(() => {831 fs.readFileSync('VERSION_TRACKER.txt', 'utf-8').should.equal('6.4.0')832 })833 })834 })835 describe('npm-shrinkwrap.json support', function () {836 beforeEach(function () {837 writeNpmShrinkwrapJson('1.0.0')838 })839 it('bumps version # in npm-shrinkwrap.json', function (done) {840 commit('feat: first commit')841 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')842 commit('feat: new feature!')843 require('./index')({ silent: true })844 .then(() => {845 JSON.parse(fs.readFileSync('npm-shrinkwrap.json', 'utf-8')).version.should.equal('1.1.0')846 getPackageVersion().should.equal('1.1.0')847 return done()848 })849 })850 })851 describe('package-lock.json support', function () {852 beforeEach(function () {853 writePackageLockJson('1.0.0')854 fs.writeFileSync('.gitignore', '', 'utf-8')855 })856 it('bumps version # in package-lock.json', function () {857 commit('feat: first commit')858 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')859 commit('feat: new feature!')860 return require('./index')({ silent: true })861 .then(() => {862 JSON.parse(fs.readFileSync('package-lock.json', 'utf-8')).version.should.equal('1.1.0')863 getPackageVersion().should.equal('1.1.0')864 })865 })866 })867 describe('dry-run', function () {868 it('skips all non-idempotent steps', function (done) {869 commit('feat: first commit')870 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')871 commit('feat: new feature!')872 execCli('--dry-run').stdout.should.match(/### Features/)873 shell.exec('git log --oneline -n1').stdout.should.match(/feat: new feature!/)874 shell.exec('git tag').stdout.should.match(/1\.0\.0/)875 getPackageVersion().should.equal('1.0.0')876 return done()877 })878 })879 describe('skip', () => {880 it('allows bump and changelog generation to be skipped', function () {881 const changelogContent = 'legacy header format<a name="1.0.0">\n'882 writePackageJson('1.0.0')883 fs.writeFileSync('CHANGELOG.md', changelogContent, 'utf-8')884 commit('feat: first commit')885 return execCliAsync('--skip.bump true --skip.changelog true')886 .then(function () {887 getPackageVersion().should.equal('1.0.0')888 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')889 content.should.equal(changelogContent)890 })891 })892 it('allows the commit phase to be skipped', function () {893 const changelogContent = 'legacy header format<a name="1.0.0">\n'894 writePackageJson('1.0.0')895 fs.writeFileSync('CHANGELOG.md', changelogContent, 'utf-8')896 commit('feat: new feature from branch')897 return execCliAsync('--skip.commit true')898 .then(function () {899 getPackageVersion().should.equal('1.1.0')900 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')901 content.should.match(/new feature from branch/)902 // check last commit message903 shell.exec('git log --oneline -n1').stdout.should.match(/feat: new feature from branch/)904 })905 })906 })907 describe('.gitignore', () => {908 beforeEach(function () {909 writeBowerJson('1.0.0')910 })911 it('does not update files present in .gitignore', () => {912 fs.writeFileSync('.gitignore', 'bower.json', 'utf-8')913 commit('feat: first commit')914 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')915 commit('feat: new feature!')916 return require('./index')({ silent: true })917 .then(() => {918 JSON.parse(fs.readFileSync('bower.json', 'utf-8')).version.should.equal('1.0.0')919 getPackageVersion().should.equal('1.1.0')920 })921 })922 })923 describe('.gitignore', () => {924 beforeEach(function () {925 writeBowerJson('1.0.0')926 })927 it('does not update files present in .gitignore', () => {928 fs.writeFileSync('.gitignore', 'bower.json', 'utf-8')929 commit('feat: first commit')930 shell.exec('git tag -a v1.0.0 -m "my awesome first release"')931 commit('feat: new feature!')932 return require('./index')({ silent: true })933 .then(() => {934 JSON.parse(fs.readFileSync('bower.json', 'utf-8')).version.should.equal('1.0.0')935 getPackageVersion().should.equal('1.1.0')936 })937 })938 })939 describe('gitTagFallback', () => {940 it('defaults to 1.0.0 if no tags in git history', () => {941 shell.rm('package.json')942 commit('feat: first commit')943 return require('./index')({ silent: true })944 .then(() => {945 const output = shell.exec('git tag')946 output.stdout.should.include('v1.1.0')947 })948 })949 it('bases version on last tag, if tags are found', () => {950 shell.rm('package.json')951 shell.exec('git tag -a v5.0.0 -m "a release"')952 shell.exec('git tag -a v3.0.0 -m "another release"')953 commit('feat: another commit')954 return require('./index')({ silent: true })955 .then(() => {956 const output = shell.exec('git tag')957 output.stdout.should.include('v5.1.0')958 })959 })960 it('does not display `npm publish` if there is no package.json', function () {961 shell.rm('package.json')962 const result = execCli()963 result.code.should.equal(0)964 result.stdout.should.not.match(/npm publish/)965 })966 })967 describe('configuration', () => {968 it('reads config from package.json', function () {969 writePackageJson('1.0.0', {970 repository: {971 url: 'git+https://company@scm.org/office/app.git'972 },973 'standard-version': {974 issueUrlFormat: 'https://standard-version.company.net/browse/{{id}}'975 }976 })977 commit('feat: another commit addresses issue #1')978 execCli()979 // CHANGELOG should have the new issue URL format.980 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')981 content.should.include('https://standard-version.company.net/browse/1')982 })983 it('reads config from .versionrc', function () {984 // write configuration that overrides default issue985 // URL format.986 fs.writeFileSync('.versionrc', JSON.stringify({987 issueUrlFormat: 'http://www.foo.com/{{id}}'988 }), 'utf-8')989 commit('feat: another commit addresses issue #1')990 execCli()991 // CHANGELOG should have the new issue URL format.992 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')993 content.should.include('http://www.foo.com/1')994 })995 it('reads config from .versionrc.json', function () {996 // write configuration that overrides default issue997 // URL format.998 fs.writeFileSync('.versionrc.json', JSON.stringify({999 issueUrlFormat: 'http://www.foo.com/{{id}}'1000 }), 'utf-8')1001 commit('feat: another commit addresses issue #1')1002 execCli()1003 // CHANGELOG should have the new issue URL format.1004 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')1005 content.should.include('http://www.foo.com/1')1006 })1007 it('evaluates a config-function from .versionrc.js', function () {1008 // write configuration that overrides default issue1009 // URL format.1010 fs.writeFileSync(1011 '.versionrc.js',1012 `module.exports = function() {1013 return {1014 issueUrlFormat: 'http://www.versionrc.js/function/{{id}}'1015 }1016 }`,1017 'utf-8'1018 )1019 commit('feat: another commit addresses issue #1')1020 execCli()1021 // CHANGELOG should have the new issue URL format.1022 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')1023 content.should.include('http://www.versionrc.js/function/1')1024 })1025 it('evaluates a config-object from .versionrc.js', function () {1026 // write configuration that overrides default issue1027 // URL format.1028 fs.writeFileSync(1029 '.versionrc.js',1030 `module.exports = {1031 issueUrlFormat: 'http://www.versionrc.js/object/{{id}}'1032 }`,1033 'utf-8'1034 )1035 commit('feat: another commit addresses issue #1')1036 execCli()1037 // CHANGELOG should have the new issue URL format.1038 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')1039 content.should.include('http://www.versionrc.js/object/1')1040 })1041 it('throws an error when a non-object is returned from .versionrc.js', function () {1042 // write configuration that overrides default issue1043 // URL format.1044 fs.writeFileSync(1045 '.versionrc.js',1046 'module.exports = 3',1047 'utf-8'1048 )1049 commit('feat: another commit addresses issue #1')1050 execCli().code.should.equal(1)1051 })1052 it('.versionrc : releaseCommitMessageFormat', function () {1053 // write configuration that overrides default issue1054 // URL format.1055 fs.writeFileSync('.versionrc', JSON.stringify({1056 releaseCommitMessageFormat: 'This commit represents release: {{currentTag}}'1057 }), 'utf-8')1058 commit('feat: another commit addresses issue #1')1059 execCli()1060 shell.exec('git log --oneline -n1').should.include('This commit represents release: 1.1.0')1061 })1062 it('--releaseCommitMessageFormat', function () {1063 commit('feat: another commit addresses issue #1')1064 execCli('--releaseCommitMessageFormat="{{currentTag}} is the version."')1065 shell.exec('git log --oneline -n1').should.include('1.1.0 is the version.')1066 })1067 it('.versionrc : issuePrefixes', function () {1068 // write configuration that overrides default issuePrefixes1069 // and reference prefix in issue URL format.1070 fs.writeFileSync('.versionrc', JSON.stringify({1071 issueUrlFormat: 'http://www.foo.com/{{prefix}}{{id}}',1072 issuePrefixes: ['ABC-']1073 }), 'utf-8')1074 commit('feat: another commit addresses issue ABC-1')1075 execCli()1076 // CHANGELOG should have the new issue URL format.1077 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')1078 content.should.include('http://www.foo.com/ABC-1')1079 })1080 it('--header', function () {1081 fs.writeFileSync('CHANGELOG.md', '', 'utf-8')1082 commit('feat: first commit')1083 execCli('--header="# Welcome to our CHANGELOG.md"').code.should.equal(0)1084 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')1085 content.should.match(/# Welcome to our CHANGELOG.md/)1086 })1087 it('--issuePrefixes and --issueUrlFormat', function () {1088 commit('feat: another commit addresses issue ABC-1')1089 execCli('--issuePrefixes="ABC-" --issueUrlFormat="http://www.foo.com/{{prefix}}{{id}}"')1090 const content = fs.readFileSync('CHANGELOG.md', 'utf-8')1091 content.should.include('http://www.foo.com/ABC-1')1092 })1093 it('[LEGACY] supports --message (and single %s replacement)', function () {1094 commit('feat: another commit addresses issue #1')1095 execCli('--message="V:%s"')1096 shell.exec('git log --oneline -n1').should.include('V:1.1.0')1097 })1098 it('[LEGACY] supports -m (and multiple %s replacements)', function () {1099 commit('feat: another commit addresses issue #1')1100 execCli('--message="V:%s is the %s."')1101 shell.exec('git log --oneline -n1').should.include('V:1.1.0 is the 1.1.0.')1102 })1103 })1104 describe('pre-major', () => {1105 it('bumps the minor rather than major, if version < 1.0.0', function () {1106 writePackageJson('0.5.0', {1107 repository: {1108 url: 'https://github.com/yargs/yargs.git'1109 }1110 })1111 commit('feat!: this is a breaking change')1112 execCli()1113 getPackageVersion().should.equal('0.6.0')1114 })1115 it('bumps major if --release-as=major specified, if version < 1.0.0', function () {1116 writePackageJson('0.5.0', {1117 repository: {1118 url: 'https://github.com/yargs/yargs.git'1119 }1120 })1121 commit('feat!: this is a breaking change')1122 execCli('-r major')1123 getPackageVersion().should.equal('1.0.0')1124 })1125 })1126})1127describe('GHSL-2020-111', function () {1128 beforeEach(initInTempFolder)1129 afterEach(finishTemp)1130 it('does not allow command injection via basic configuration', function () {1131 return standardVersion({1132 silent: true,1133 noVerify: true,1134 infile: 'foo.txt',1135 releaseCommitMessageFormat: 'bla `touch exploit`'1136 }).then(function () {...

Full Screen

Full Screen

cliTest.js

Source:cliTest.js Github

copy

Full Screen

...5const os = require('os');6describe('Test for simplest CLI app', function () {7 describe('Data from arguments', function () {8 it('should exit with code 1 if no numbers provided', function (done) {9 execCli([], function (err, stdout, stderr) {10 assert.isNotNull(err, 'error should be passed to callback');11 assert.strictEqual(err.code, 1, 'error code should be 1');12 done();13 });14 });15 it('should exit with code 1 if only one number provided ', function (done) {16 execCli(['1'], function (err, stdout, stderr) {17 assert.isNotNull(err, 'error should be passed to callback');18 assert.strictEqual(err.code, 1, 'error code should be 1');19 done();20 });21 });22 it('should exit with code 2 if more than 10 arguments provided', function (done) {23 execCli(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11'], function (err, stdout, stderr) {24 assert.isNotNull(err, 'error should be passed to callback');25 assert.strictEqual(err.code, 2, 'error code should be 2');26 done();27 });28 });29 it('should return sum of the numbers', function (done) {30 execCli(['1', '2', '3'], function (err, stdout, stderr) {31 assert.isNull(err, 'no error should be passed to callback');32 assert.strictEqual(stdout, '6', 'sum of 1 2 3 should be 6');33 done();34 });35 });36 });37 describe('Data from stdin', function () {38 it('should exit with code 1 if empty string is provided into stdin', function (done) {39 const child = execCli(['--stdin'], function (err, stdout, stderr) {40 assert.isNotNull(err, 'error should be passed to callback');41 assert.strictEqual(err.code, 1, 'error code should be 1');42 done();43 });44 child.stdin.end('');45 });46 it('should exit with code 1 if only one number provided ', function (done) {47 const child = execCli(['--stdin'], function (err, stdout, stderr) {48 assert.isNotNull(err, 'error should be passed to callback');49 assert.strictEqual(err.code, 1, 'error code should be 1');50 done();51 });52 child.stdin.end('1');53 });54 it('should exit with code 2 if more than 10 arguments provided', function (done) {55 const child = execCli(['--stdin'], function (err, stdout, stderr) {56 assert.isNotNull(err, 'error should be passed to callback');57 assert.strictEqual(err.code, 2, 'error code should be 2');58 done();59 });60 child.stdin.end('1 2 3 4 5 6 7 8 9 10 11');61 });62 it('should return sum of the numbers', function (done) {63 const child = execCli(['--stdin'], function (err, stdout, stderr) {64 assert.isNull(err, 'no error should be passed to callback');65 assert.strictEqual(stdout, '6', 'sum of 1 2 3 should be 6');66 done();67 });68 child.stdin.end('1 2 3');69 });70 });71});72function execCli(args, options, cb) {73 let filePath = path.resolve(__dirname, '..', 'npm-like-bin', 'cli');74 // Specify extension for Windows executable to avoid ENOENT errors 75 if (os.platform() === 'win32') {76 filePath += '.cmd';77 }78 if (isFunction(options)) {79 cb = options;80 }81 return cp.execFile(filePath, args, function (error, stdout, stderr) {82 cb(error, stdout.trim(), stderr.trim());83 });84}85function isFunction(fn) {86 return ({}).toString.call(fn) === '[object Function]';...

Full Screen

Full Screen

cli-test.js

Source:cli-test.js Github

copy

Full Screen

...10 cb);11 return child.stdin;12}13test('cli - hash', function (t){14 var stdin = execCli(['hash', 'password'], function (err, stdout){15 t.ifError(err);16 credential().verify(stdout, 'password', function (err, valid){17 t.ifError(err);18 t.ok(valid);19 t.end();20 });21 });22 stdin.end();23});24test('cli - hash - stdin', function (t){25 var stdin = execCli(['hash', '-'], function (err, stdout){26 t.ifError(err);27 credential().verify(stdout, 'password', function (err, valid){28 t.ifError(err);29 t.ok(valid);30 t.end();31 });32 });33 stdin.write('password');34 stdin.end();35});36test('cli - verify', function (t){37 credential().hash('password', function (err, hash){38 t.ifError(err);39 var stdin = execCli(['verify', hash, 'password'], function (err, stdout){40 t.ifError(err);41 var actual = stdout.trim();42 var expected = 'Verified';43 t.is(actual, expected);44 t.end();45 });46 stdin.end();47 });48});49test('cli - verify - stdin', function (t){50 credential().hash('password', function (err, hash){51 t.ifError(err);52 var stdin = execCli(['verify', '-', 'password'], function (err, stdout){53 t.ifError(err);54 var actual = stdout.trim();55 var expected = 'Verified';56 t.is(actual, expected);57 t.end();58 });59 stdin.write(hash);60 stdin.end();61 });62});63test('cli - hash - no password', function (t){64 var stdin = execCli(['hash'], function (err, stdout, stderr){65 t.ifError(err);66 var actual = stderr.trim();67 var expected = /Error: Password must be a non-empty string/;68 t.ok(expected.test(actual));69 t.end();70 });71 stdin.end();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import execa from 'execa';2import test from 'ava';3test('execCli', async t => {4 const result = await execa('ava', ['test.js']);5 t.is(result.stdout, 'foo');6});7import execa from 'execa';8import test from 'ava';9test('execCli', async t => {10 const result = await execa('ava', ['test.js']);11 t.is(result.stdout, 'foo');12});13import execa from 'execa';14import test from 'ava';15test('execCli', async t => {16 const result = await execa('ava', ['test.js']);17 t.is(result.stdout, 'foo');18});19import execa from 'execa';20import test from 'ava';21test('execCli', async t => {22 const result = await execa('ava', ['test.js']);23 t.is(result.stdout, 'foo');24});25import execa from 'execa';26import test from 'ava';27test('execCli', async t => {28 const result = await execa('ava', ['test.js']);29 t.is(result.stdout, 'foo');30});31import execa from 'execa';32import test from 'ava';33test('execCli', async t => {34 const result = await execa('ava', ['test.js']);35 t.is(result.stdout, 'foo');36});37import execa from 'execa';38import test from 'ava';39test('execCli', async t => {40 const result = await execa('ava', ['test.js']);41 t.is(result.stdout, 'foo');42});43import execa from 'execa';44import test from 'ava';45test('execCli', async t => {46 const result = await execa('ava', ['test.js']);47 t.is(result.stdout, 'foo');48});

Full Screen

Using AI Code Generation

copy

Full Screen

1const test = require('ava');2test('execCli', async t => {3 const result = await test.run(['test.js']);4 t.is(result.passed, 1);5 t.is(result.failed, 0);6});7const test = require('ava');8test('execCli', async t => {9 const result = await test.run(['test2.js']);10 t.is(result.passed, 1);11 t.is(result.failed, 0);12});13const test = require('ava');14test('execCli', async t => {15 const result = await test.run(['test3.js']);16 t.is(result.passed, 1);17 t.is(result.failed, 0);18});19const test = require('ava');20test('execCli', async t => {21 const result = await test.run(['test4.js']);22 t.is(result.passed, 1);23 t.is(result.failed, 0);24});25const test = require('ava');26test('execCli', async t => {27 const result = await test.run(['test5.js']);28 t.is(result.passed, 1);29 t.is(result.failed, 0);30});31const test = require('ava');32test('execCli', async t => {33 const result = await test.run(['test6.js']);34 t.is(result.passed, 1);35 t.is(result.failed, 0);36});37const test = require('ava');38test('execCli', async t => {39 const result = await test.run(['test7.js']);40 t.is(result.passed, 1);41 t.is(result.failed, 0);42});43const test = require('ava');44test('execCli', async t => {45 const result = await test.run(['test8.js']);46 t.is(result.passed,

Full Screen

Using AI Code Generation

copy

Full Screen

1const test = require('ava');2const execCli = require('execa').sync;3test('test', t => {4 const result = execCli('node', ['index.js']);5 console.log(result.stdout);6 console.log(result.stderr);7 console.log(result.exitCode);8 console.log(result.failed);9 console.log(result.killed);10 console.log(result.signal);11 console.log(result.timedOut);12});13console.log('Hello World');

Full Screen

Using AI Code Generation

copy

Full Screen

1const execCli = require('ava').execCli;2execCli(['test.js'], {cwd: __dirname}).then(result => {3 console.log(result);4});5const execCli = require('ava').execCli;6execCli(['test.js'], {cwd: __dirname}).then(result => {7 console.log(result);8});9const execCli = require('ava').execCli;10execCli(['test.js'], {cwd: __dirname}).then(result => {11 console.log(result);12});13const execCli = require('ava').execCli;14execCli(['test.js'], {cwd: __dirname}).then(result => {15 console.log(result);16});17const execCli = require('ava').execCli;18execCli(['test.js'], {cwd: __dirname}).then(result => {19 console.log(result);20});21const execCli = require('ava').execCli;22execCli(['test.js'], {cwd: __dirname}).then(result => {23 console.log(result);24});25const execCli = require('ava').execCli;26execCli(['test.js'], {cwd: __dirname}).then(result => {27 console.log(result);28});29const execCli = require('ava').execCli;30execCli(['test.js'], {cwd: __dirname}).then(result => {31 console.log(result);32});33const execCli = require('ava').execCli;34execCli(['test.js'], {cwd: __dirname}).then(result => {35 console.log(result);36});37const execCli = require('ava').execCli;38execCli(['test.js'], {cwd: __dirname}).then(result => {39 console.log(result);40});

Full Screen

Using AI Code Generation

copy

Full Screen

1const execCli = require('ava/cli').execCli;2execCli(['test'], {cwd: 'test'}, (err, result) => {3 if (err) {4 throw err;5 }6 console.log(result);7});8import test from 'ava';9test('should return "Hello World"', t => {10 t.is('Hello World', 'Hello World');11});12{ exitCode: 0,13 stderr: '' }

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ava automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful