From 359a508bee591d6059bcf1aefa7fc018a1af7a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CPooja?= Date: Fri, 16 Sep 2022 13:48:53 -0700 Subject: [PATCH] test: changed promise to async/await in debugger-watcher --- test/sequential/test-debugger-watchers.js | 48 --------------------- test/sequential/test-debugger-watchers.mjs | 49 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 48 deletions(-) delete mode 100644 test/sequential/test-debugger-watchers.js create mode 100644 test/sequential/test-debugger-watchers.mjs diff --git a/test/sequential/test-debugger-watchers.js b/test/sequential/test-debugger-watchers.js deleted file mode 100644 index e856132b74e28a..00000000000000 --- a/test/sequential/test-debugger-watchers.js +++ /dev/null @@ -1,48 +0,0 @@ -'use strict'; -const common = require('../common'); - -common.skipIfInspectorDisabled(); - -const fixtures = require('../common/fixtures'); -const startCLI = require('../common/debugger'); - -const assert = require('assert'); - -// Stepping through breakpoints. -{ - const cli = startCLI([fixtures.path('debugger/break.js')]); - - function onFatal(error) { - cli.quit(); - throw error; - } - - return cli.waitForInitialBreak() - .then(() => cli.waitForPrompt()) - .then(() => cli.command('watch("x")')) - .then(() => cli.command('watch("\\"Hello\\"")')) - .then(() => cli.command('watch("42")')) - .then(() => cli.command('watch("NaN")')) - .then(() => cli.command('watch("true")')) - .then(() => cli.command('watch("[1, 2]")')) - .then(() => cli.command('watch("process.env")')) - .then(() => cli.command('watchers')) - .then(() => { - assert.match(cli.output, /x is not defined/); - }) - .then(() => cli.command('unwatch("42")')) - .then(() => cli.stepCommand('n')) - .then(() => { - assert.match(cli.output, /0: x = 10/); - assert.match(cli.output, /1: "Hello" = 'Hello'/); - assert.match(cli.output, /2: NaN = NaN/); - assert.match(cli.output, /3: true = true/); - assert.match(cli.output, /4: \[1, 2\] = \[ 1, 2 \]/); - assert.match( - cli.output, - /5: process\.env =\n\s+\{[\s\S]+,\n\s+\.\.\. \}/, - 'shows "..." for process.env'); - }) - .then(() => cli.quit()) - .then(null, onFatal); -} diff --git a/test/sequential/test-debugger-watchers.mjs b/test/sequential/test-debugger-watchers.mjs new file mode 100644 index 00000000000000..a6bc4c83aca773 --- /dev/null +++ b/test/sequential/test-debugger-watchers.mjs @@ -0,0 +1,49 @@ +import { skipIfInspectorDisabled } from '../common/index.mjs'; +skipIfInspectorDisabled(); + +import { path } from '../common/fixtures.mjs'; +import startCLI from '../common/debugger.js'; + +import assert from 'assert'; + +function onFatal(error) { + cli.quit(); + throw error; +} + +// Stepping through breakpoints. +try { + const script = path('debugger', 'break.js'); + const cli = startCLI([script]); + + await cli.waitForInitialBreak(); + await cli.waitForPrompt(); + await cli.command('watch("x")'); + await cli.command('watch("\\"Hello\\"")'); + await cli.command('watch("42")'); + await cli.command('watch("NaN")'); + await cli.command('watch("true")'); + await cli.command('watch("[1, 2]")'); + await cli.command('watch("process.env")'); + await cli.command('watchers'); + + assert.match(cli.output, /x is not defined/); + + await cli.command('unwatch("42")'); + await cli.stepCommand('n'); + + assert.match(cli.output, /0: x = 10/); + assert.match(cli.output, /1: "Hello" = 'Hello'/); + assert.match(cli.output, /2: NaN = NaN/); + assert.match(cli.output, /3: true = true/); + assert.match(cli.output, /4: \[1, 2\] = \[ 1, 2 \]/); + assert.match( + cli.output, + /5: process\.env =\n\s+\{[\s\S]+,\n\s+\.\.\. \}/, + 'shows "..." for process.env' + ); + + await cli.quit(); +} catch(error) { + onFatal(error) +} \ No newline at end of file