diff --git a/samples/package.json b/samples/package.json index 23569cbf..4b196167 100644 --- a/samples/package.json +++ b/samples/package.json @@ -9,7 +9,7 @@ "node": ">=8" }, "scripts": { - "test": "ava -T 20s --verbose system-test/*.test.js" + "test": "mocha system-test/*.test.js --timeout 600000" }, "dependencies": { "@google-cloud/speech": "^2.1.1", @@ -19,7 +19,7 @@ }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "^2.3.0", - "ava": "^0.25.0", + "mocha": "^5.2.0", "proxyquire": "^2.0.1", "sinon": "^7.0.0", "uuid": "^3.3.0" diff --git a/samples/system-test/.eslintrc.yml b/samples/system-test/.eslintrc.yml index c0289282..75216436 100644 --- a/samples/system-test/.eslintrc.yml +++ b/samples/system-test/.eslintrc.yml @@ -1,4 +1,6 @@ --- +env: + mocha: true rules: node/no-unpublished-require: off node/no-unsupported-features: off diff --git a/samples/system-test/MicrophoneStream.test.js b/samples/system-test/MicrophoneStream.test.js index fa385777..aff8f188 100644 --- a/samples/system-test/MicrophoneStream.test.js +++ b/samples/system-test/MicrophoneStream.test.js @@ -16,15 +16,17 @@ 'use strict'; const path = require(`path`); -const test = require(`ava`); +const assert = require(`assert`); const {runAsync} = require(`@google-cloud/nodejs-repo-tools`); const cmd = `node MicrophoneStream.js`; const cwd = path.join(__dirname, `..`); -test(`MicrophoneStream.js Should load and display Yaaaarghs(!) correctly`, async t => { - const output = await runAsync(`${cmd} --help`, cwd); - t.true( - output.includes('Streams audio input from microphone, translates to text') - ); +describe(`MicrophoneStream`, () => { + it(`MicrophoneStream.js Should load and display Yaaaarghs(!) correctly`, async () => { + const output = await runAsync(`${cmd} --help`, cwd); + assert.ok( + output.includes('Streams audio input from microphone, translates to text') + ); + }); }); diff --git a/samples/system-test/betaFeatures.test.js b/samples/system-test/betaFeatures.test.js index 1a080fd8..2242cc1e 100644 --- a/samples/system-test/betaFeatures.test.js +++ b/samples/system-test/betaFeatures.test.js @@ -18,7 +18,7 @@ 'use strict'; const path = require(`path`); -const test = require(`ava`); +const assert = require(`assert`); const {runAsync} = require(`@google-cloud/nodejs-repo-tools`); @@ -48,63 +48,77 @@ const multiUri = `gs://nodejs-docs-samples/multi_mono.wav`; const brooklynUri = `gs://cloud-samples-tests/speech/brooklyn.flac`; const stereoUri = `gs://cloud-samples-tests/speech/commercial_stereo.wav`; -test(`should run speech diarization on a local file`, async t => { - const output = await runAsync(`${cmd} Diarization -f ${monoFilePath}`, cwd); - t.true(output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`)); -}); - -test(`should run speech diarization on a GCS file`, async t => { - const output = await runAsync(`${cmd} DiarizationGCS -u ${monoUri}`, cwd); - t.true(output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`)); -}); - -test(`should run multi channel transcription on a local file`, async t => { - const output = await runAsync( - `${cmd} multiChannelTranscribe -f ${stereoFilePath}`, - cwd - ); - t.true(output.includes(`Channel Tag: 2`)); -}); - -test(`should run multi channel transcription on GCS file`, async t => { - const output = await runAsync( - `${cmd} multiChannelTranscribeGCS -u ${stereoUri}`, - cwd - ); - t.true(output.includes(`Channel Tag: 2`)); -}); - -test(`should transcribe multi-language on a local file`, async t => { - const output = await runAsync( - `${cmd} multiLanguageTranscribe -f ${multiLanguageFile}`, - cwd - ); - t.true(output.includes(`Transcription: how are you doing estoy bien e tu`)); -}); - -test(`should transcribe multi-language on a GCS bucket`, async t => { - const output = await runAsync( - `${cmd} multiLanguageTranscribeGCS -u ${multiUri}`, - cwd - ); - t.true(output.includes(`Transcription: how are you doing estoy bien e tu`)); -}); - -test(`should run word Level Confience on a local file`, async t => { - const output = await runAsync( - `${cmd} wordLevelConfidence -f ${BrooklynFilePath}` - ); - t.true(output.includes(`Transcription: how old is the Brooklyn Bridge`)); - t.true(/Confidence: \d\.\d/.test(output)); -}); - -test(`should run word level confidence on a GCS bucket`, async t => { - const output = await runAsync( - `${cmd} wordLevelConfidenceGCS -u ${brooklynUri}`, - cwd - ); - t.true( - output.includes(`Transcription: how old is the Brooklyn Bridge`) && - /Confidence: \d\.\d/.test(output) - ); +describe(`BetaFeatures`, () => { + + it(`should run speech diarization on a local file`, async () => { + const output = await runAsync( + `${cmd} Diarization -f ${monoFilePath}`, + cwd + ); + assert.ok( + output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`) + ); + }); + + it(`should run speech diarization on a GCS file`, async () => { + const output = await runAsync(`${cmd} DiarizationGCS -u ${monoUri}`, cwd); + assert.ok( + output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`) + ); + }); + + it(`should run multi channel transcription on a local file`, async () => { + const output = await runAsync( + `${cmd} multiChannelTranscribe -f ${stereoFilePath}`, + cwd + ); + assert.ok(output.includes(`Channel Tag: 2`)); + }); + + it(`should run multi channel transcription on GCS file`, async () => { + const output = await runAsync( + `${cmd} multiChannelTranscribeGCS -u ${stereoUri}`, + cwd + ); + assert.ok(output.includes(`Channel Tag: 2`)); + }); + + it(`should transcribe multi-language on a local file`, async () => { + const output = await runAsync( + `${cmd} multiLanguageTranscribe -f ${multiLanguageFile}`, + cwd + ); + assert.ok(output.includes(`Transcription: how are you doing estoy bien e tu`)); + }); + + it(`should transcribe multi-language on a GCS bucket`, async () => { + const output = await runAsync( + `${cmd} multiLanguageTranscribeGCS -u ${multiUri}`, + cwd + ); + assert.ok( + output.includes(`Transcription: how are you doing estoy bien e tu`) + ); + }); + + it(`should run word Level Confience on a local file`, async () => { + const output = await runAsync( + `${cmd} wordLevelConfidence -f ${BrooklynFilePath}` + ); + assert.ok( + output.includes(`Transcription: how old is the Brooklyn Bridge`) + ); + assert.ok(/Confidence: \d\.\d/.test(output)); + }); + + it(`should run word level confidence on a GCS bucket`, async () => { + const output = await runAsync( + `${cmd} wordLevelConfidenceGCS -u ${brooklynUri}`, + cwd + ); + assert.ok( + output.includes(`Transcription: how old is the Brooklyn Bridge`) && + /Confidence: \d\.\d/.test(output) + ); + }); }); diff --git a/samples/system-test/quickstart.test.js b/samples/system-test/quickstart.test.js index 56dd390d..9d0b2c28 100644 --- a/samples/system-test/quickstart.test.js +++ b/samples/system-test/quickstart.test.js @@ -18,7 +18,7 @@ 'use strict'; const path = require(`path`); -const test = require(`ava`); +const assert = require(`assert`); const cmd = `node quickstart.js`; const cwd = path.join(__dirname, `..`); @@ -26,9 +26,9 @@ const text = `how old is the Brooklyn Bridge`; const {runAsync} = require(`@google-cloud/nodejs-repo-tools`); -test.before(async () => {}); - -test(`should run quickstart`, async t => { - const output = await runAsync(`${cmd}`, cwd); - t.true(output.includes(`Transcription: ${text}`)); +describe(`Quickstart`, () => { + it(`should run quickstart`, async () => { + const output = await runAsync(`${cmd}`, cwd); + assert.ok(output.includes(`Transcription: ${text}`)); + }); }); diff --git a/samples/system-test/recognize.test.js b/samples/system-test/recognize.test.js index 700ad25b..da595c19 100644 --- a/samples/system-test/recognize.test.js +++ b/samples/system-test/recognize.test.js @@ -17,7 +17,7 @@ const path = require(`path`); const {Storage} = require(`@google-cloud/storage`); -const test = require(`ava`); +const assert = require(`assert`); const uuid = require(`uuid`); const {runAsync} = require(`@google-cloud/nodejs-repo-tools`); @@ -37,92 +37,100 @@ const text1 = `the weather outside is sunny`; const text2 = `Terrific. It's on the way.`; const text3 = `Chrome`; -test.before(async () => { - const [bucket] = await storage.createBucket(bucketName); - await bucket.upload(filepath); - await bucket.upload(filepath1); -}); - -test.after.always(async () => { - const bucket = storage.bucket(bucketName); - await bucket.deleteFiles({force: true}); - await bucket.deleteFiles({force: true}); // Try a second time... - await bucket.delete(); -}); - -test(`should run sync recognize`, async t => { - const output = await runAsync(`${cmd} sync ${filepath}`, cwd); - t.true(output.includes(`Transcription: ${text}`)); -}); - -test(`should run sync recognize on a GCS file`, async t => { - const output = await runAsync( - `${cmd} sync-gcs gs://${bucketName}/${filename}`, - cwd - ); - t.true(output.includes(`Transcription: ${text}`)); -}); - -test(`should run sync recognize with word time offset`, async t => { - const output = await runAsync(`${cmd} sync-words ${filepath}`, cwd); - t.true(output.includes(`Transcription: ${text}`)); - t.true(new RegExp(`\\d+\\.\\d+ secs - \\d+\\.\\d+ secs`).test(output)); -}); - -test(`should run async recognize on a local file`, async t => { - const output = await runAsync(`${cmd} async ${filepath}`, cwd); - t.true(output.includes(`Transcription: ${text}`)); -}); - -test(`should run async recognize on a GCS file`, async t => { - const output = await runAsync( - `${cmd} async-gcs gs://${bucketName}/${filename}`, - cwd - ); - t.true(output.includes(`Transcription: ${text}`)); -}); - -test(`should run async recognize on a GCS file with word time offset`, async t => { - const output = await runAsync( - `${cmd} async-gcs-words gs://${bucketName}/${filename}`, - cwd - ); - t.true(output.includes(`Transcription: ${text}`)); - // Check for word time offsets - t.true(new RegExp(`\\d+\\.\\d+ secs - \\d+\\.\\d+ secs`).test(output)); -}); - -test(`should run streaming recognize`, async t => { - const output = await runAsync(`${cmd} stream ${filepath}`, cwd); - t.true(output.includes(`Transcription: ${text}`)); -}); - -test(`should run sync recognize with model selection`, async t => { - const model = `video`; - const output = await runAsync(`${cmd} sync-model ${filepath1} ${model}`, cwd); - t.true(output.includes(`Transcription:`)); - t.true(output.includes(text1)); -}); - -test(`should run sync recognize on a GCS file with model selection`, async t => { - const model = `video`; - const output = await runAsync( - `${cmd} sync-model-gcs gs://${bucketName}/${filename1} ${model}`, - cwd - ); - t.true(output.includes(`Transcription:`)); - t.true(output.includes(text1)); -}); - -test(`should run sync recognize with auto punctuation`, async t => { - const output = await runAsync( - `${cmd} sync-auto-punctuation ${filepath2}`, - cwd - ); - t.true(output.includes(text2)); -}); - -test(`should run sync recognize with enhanced model`, async t => { - const output = await runAsync(`${cmd} sync-enhanced-model ${filepath2}`, cwd); - t.true(output.includes(text3)); +describe(`Recognize`, () => { + before(async () => { + const [bucket] = await storage.createBucket(bucketName); + await bucket.upload(filepath); + await bucket.upload(filepath1); + }); + + after(async () => { + const bucket = storage.bucket(bucketName); + await bucket.deleteFiles({force: true}); + await bucket.deleteFiles({force: true}); // Try a second time... + await bucket.delete(); + }); + + it(`should run sync recognize`, async () => { + const output = await runAsync(`${cmd} sync ${filepath}`, cwd); + assert.ok(output.includes(`Transcription: ${text}`)); + }); + + it(`should run sync recognize on a GCS file`, async () => { + const output = await runAsync( + `${cmd} sync-gcs gs://${bucketName}/${filename}`, + cwd + ); + assert.ok(output.includes(`Transcription: ${text}`)); + }); + + it(`should run sync recognize with word time offset`, async () => { + const output = await runAsync(`${cmd} sync-words ${filepath}`, cwd); + assert.ok(output.includes(`Transcription: ${text}`)); + assert.ok(new RegExp(`\\d+\\.\\d+ secs - \\d+\\.\\d+ secs`).test(output)); + }); + + it(`should run async recognize on a local file`, async () => { + const output = await runAsync(`${cmd} async ${filepath}`, cwd); + assert.ok(output.includes(`Transcription: ${text}`)); + }); + + it(`should run async recognize on a GCS file`, async () => { + const output = await runAsync( + `${cmd} async-gcs gs://${bucketName}/${filename}`, + cwd + ); + assert.ok(output.includes(`Transcription: ${text}`)); + }); + + it(`should run async recognize on a GCS file with word time offset`, async () => { + const output = await runAsync( + `${cmd} async-gcs-words gs://${bucketName}/${filename}`, + cwd + ); + assert.ok(output.includes(`Transcription: ${text}`)); + // Check for word time offsets + assert.ok(new RegExp(`\\d+\\.\\d+ secs - \\d+\\.\\d+ secs`).test(output)); + }); + + it(`should run streaming recognize`, async () => { + const output = await runAsync(`${cmd} stream ${filepath}`, cwd); + assert.ok(output.includes(`Transcription: ${text}`)); + }); + + it(`should run sync recognize with model selection`, async () => { + const model = `video`; + const output = await runAsync( + `${cmd} sync-model ${filepath1} ${model}`, + cwd + ); + assert.ok(output.includes(`Transcription:`)); + assert.ok(output.includes(text1)); + }); + + it(`should run sync recognize on a GCS file with model selection`, async () => { + const model = `video`; + const output = await runAsync( + `${cmd} sync-model-gcs gs://${bucketName}/${filename1} ${model}`, + cwd + ); + assert.ok(output.includes(`Transcription:`)); + assert.ok(output.includes(text1)); + }); + + it(`should run sync recognize with auto punctuation`, async () => { + const output = await runAsync( + `${cmd} sync-auto-punctuation ${filepath2}`, + cwd + ); + assert.ok(output.includes(text2)); + }); + + it(`should run sync recognize with enhanced model`, async () => { + const output = await runAsync( + `${cmd} sync-enhanced-model ${filepath2}`, + cwd + ); + assert.ok(output.includes(text3)); + }); }); diff --git a/samples/system-test/recognize.v1p1beta1.test.js b/samples/system-test/recognize.v1p1beta1.test.js index 792850b5..8699ae7e 100644 --- a/samples/system-test/recognize.v1p1beta1.test.js +++ b/samples/system-test/recognize.v1p1beta1.test.js @@ -17,7 +17,7 @@ const path = require(`path`); const {Storage} = require(`@google-cloud/storage`); -const test = require(`ava`); +const assert = require(`assert`); const uuid = require(`uuid`); const {runAsync} = require(`@google-cloud/nodejs-repo-tools`); const storage = new Storage(); @@ -31,19 +31,21 @@ const filepath2 = path.join(__dirname, `../resources/${filename2}`); const text = `Chrome`; -test.before(async () => { - const [bucket] = await storage.createBucket(bucketName); - await bucket.upload(filepath1); -}); +describe(`Recognize v1p1beta1`, () => { + before(async () => { + const [bucket] = await storage.createBucket(bucketName); + await bucket.upload(filepath1); + }); -test.after.always(async () => { - const bucket = storage.bucket(bucketName); - await bucket.deleteFiles({force: true}); - await bucket.deleteFiles({force: true}); // Try a second time... - await bucket.delete(); -}); + after(async () => { + const bucket = storage.bucket(bucketName); + await bucket.deleteFiles({force: true}); + await bucket.deleteFiles({force: true}); // Try a second time... + await bucket.delete(); + }); -test(`should run sync recognize with metadata`, async t => { - const output = await runAsync(`${cmd} sync-metadata ${filepath2}`, cwd); - t.true(output.includes(text)); + it(`should run sync recognize with metadata`, async () => { + const output = await runAsync(`${cmd} sync-metadata ${filepath2}`, cwd); + assert.ok(output.includes(text)); + }); });