xref: /third_party/node/test/es-module/test-esm-error-cache.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/es-module/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst file = '../fixtures/syntax/bad_syntax.mjs';
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_cilet error;
91cb0ef41Sopenharmony_ci(async () => {
101cb0ef41Sopenharmony_ci  try {
111cb0ef41Sopenharmony_ci    await import(file);
121cb0ef41Sopenharmony_ci  } catch (e) {
131cb0ef41Sopenharmony_ci    assert.strictEqual(e.name, 'SyntaxError');
141cb0ef41Sopenharmony_ci    error = e;
151cb0ef41Sopenharmony_ci  }
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  assert(error);
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci  await assert.rejects(
201cb0ef41Sopenharmony_ci    () => import(file),
211cb0ef41Sopenharmony_ci    (e) => {
221cb0ef41Sopenharmony_ci      assert.strictEqual(error, e);
231cb0ef41Sopenharmony_ci      return true;
241cb0ef41Sopenharmony_ci    }
251cb0ef41Sopenharmony_ci  );
261cb0ef41Sopenharmony_ci})().then(common.mustCall());
27

Indexes created Thu Nov 07 10:32:03 CST 2024