From 534eb748558b48bfc7a86c7cdfa1f7b769bedd2e Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Sun, 1 Oct 2023 18:49:48 +0530 Subject: [PATCH] fix: add post test and fix tests --- package.json | 3 ++- test/integration/validate.test.ts | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 7febb653a23..3048a2de6d1 100644 --- a/package.json +++ b/package.json @@ -147,9 +147,10 @@ "prepublishOnly": "npm run build", "pretest": "npm run build", "pretest:coverage": "npm run build", + "posttest": "rimraf ./test.asyncapi-cli", "release": "semantic-release", "test": "npm run test:unit", - "test:unit": "cross-env NODE_ENV=development TEST=1 CUSTOM_CONTEXT_FILENAME=\"test.asyncapi-cli\" CUSTOM_CONTEXT_FILE_LOCATION=\"\" nyc --extension .ts mocha --require ts-node/register --require test/helpers/init.js --reporter spec --timeout 100000 \"test/**/*.test.ts\" && rimraf ./test.asyncapi-cli", + "test:unit": "cross-env NODE_ENV=development TEST=1 CUSTOM_CONTEXT_FILENAME=\"test.asyncapi-cli\" CUSTOM_CONTEXT_FILE_LOCATION=\"\" nyc --extension .ts mocha --require ts-node/register --require test/helpers/init.js --reporter spec --timeout 100000 \"test/**/*.test.ts\"", "get-version": "echo $npm_package_version" }, "types": "lib/index.d.ts" diff --git a/test/integration/validate.test.ts b/test/integration/validate.test.ts index 3febd8abfb0..c0298279bc9 100644 --- a/test/integration/validate.test.ts +++ b/test/integration/validate.test.ts @@ -71,7 +71,7 @@ describe('validate', () => { .stdout() .command(['validate', './test/fixtures/valid-specification-latest.yml']) .it('works when file path is passed', (ctx, done) => { - expect(ctx.stdout).to.match(/File .\/test\/fixtures\/valid-specification.yml is valid! File .\/test\/fixtures\/valid-specification.yml and referenced documents don't have governance issues./); + expect(ctx.stdout).to.include('File ./test/fixtures/valid-specification-latest.yml is valid! File ./test/fixtures/valid-specification-latest.yml and referenced documents don\'t have governance issues.'); expect(ctx.stderr).to.equal(''); done(); }); @@ -220,7 +220,7 @@ describe('validate', () => { .stdout() .command(['validate', './test/fixtures/valid-specification-latest.yml', '--diagnostics-format=text']) .it('works with --diagnostics-format flag (without governance issues)', (ctx, done) => { - expect(ctx.stdout).to.match(new RegExp('File ./test/fixtures/valid-specification.yml is valid! File ./test/fixtures/valid-specification.yml and referenced documents don\'t have governance issues.')); + expect(ctx.stdout).to.include('\nFile ./test/fixtures/valid-specification-latest.yml is valid! File ./test/fixtures/valid-specification-latest.yml and referenced documents don\'t have governance issues.'); expect(ctx.stderr).to.equal(''); done(); }); @@ -240,7 +240,7 @@ describe('validate', () => { .stdout() .command(['validate', './test/fixtures/specification.yml', '--fail-severity=warn']) .it('works with --fail-severity', (ctx, done) => { - expect(ctx.stderr).to.match(new RegExp('File ./test/fixtures/specification.yml and\\/or referenced documents have governance issues.\\n\\ntest\\/fixtures\\/specification.yml')); + expect(ctx.stderr).to.include('\nFile ./test/fixtures/specification.yml and/or referenced documents have governance issues.\n\ntest/fixtures/specification.yml'); done(); }); });