summaryrefslogtreecommitdiff
path: root/test/parallel/test-vm-module-errors.js
Commit message (Collapse)AuthorAgeFilesLines
* errors,vm: update error and use causeGus Caplan2022-04-241-5/+10
| | | | | | | | PR-URL: https://github.com/nodejs/node/pull/42820 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
* test: prepare for consistent comma-dangle lint ruleRich Trott2021-04-011-2/+2
| | | | | | | | | Make changes so that tests will pass when the comma-dangle settings applied to the rest of the code base are also applied to tests. PR-URL: https://github.com/nodejs/node/pull/37930 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
* test: improve coverage of `SourceTextModule` gettersJuan José Arboleda2021-01-241-4/+14
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/37013 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* test: improve coverage for `Module` gettersJuan José Arboleda2021-01-181-1/+26
| | | | | | PR-URL: https://github.com/nodejs/node/pull/36950 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
* tools: enable no-unused-expressions lint ruleMichaël Zasso2020-12-071-3/+3
| | | | | | | | | | | | | Fixes: https://github.com/nodejs/node/issues/36246 PR-URL: https://github.com/nodejs/node/pull/36248 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* test: use `.then(common.mustCall())` for all async IIFEsAnna Henningsen2020-07-201-1/+1
| | | | | | | | | | | | This makes sure that all async functions finish as expected. PR-URL: https://github.com/nodejs/node/pull/34363 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
* src: add support for TLAGus Caplan2020-05-141-4/+2
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/30370 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
* test: check args on SourceTextModule cachedDataJuan José Arboleda2020-04-291-0/+17
| | | | | | PR-URL: https://github.com/nodejs/node/pull/32956 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host>
* test: refactor common.expectsErrorRuben Bridgewater2019-12-311-8/+8
| | | | | | | | | | | | | | | | | | | | | | | This completely refactors the `expectsError` behavior: so far it's almost identical to `assert.throws(fn, object)` in case it was used with a function as first argument. It had a magical property check that allowed to verify a functions `type` in case `type` was passed used in the validation object. This pattern is now completely removed and `assert.throws()` should be used instead. The main intent for `common.expectsError()` is to verify error cases for callback based APIs. This is now more flexible by accepting all validation possibilites that `assert.throws()` accepts as well. No magical properties exist anymore. This reduces surprising behavior for developers who are not used to the Node.js core code base. This has the side effect that `common` is used significantly less frequent. PR-URL: https://github.com/nodejs/node/pull/31092 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* errors: improve ERR_INVALID_ARG_TYPERuben Bridgewater2019-12-201-5/+5
| | | | | | | | | | | | | | ERR_INVALID_ARG_TYPE is the most common error used throughout the code base. This improves the error message by providing more details to the user and by indicating more precisely which values are allowed ones and which ones are not. It adds the actual input to the error message in case it's a primitive. If it's a class instance, it'll print the class name instead of "object" and "falsy" or similar entries are not named "type" anymore. PR-URL: https://github.com/nodejs/node/pull/29675 Reviewed-By: Rich Trott <rtrott@gmail.com>
* test: changed var to let in module-errorsJamar Torres2019-11-241-1/+1
| | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/30413 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* vm: add Synthetic modulesGus Caplan2019-10-141-1/+1
| | | | | | | | | | | - Refactor vm.SourceTextModule (again) - Add vm.Module abstract superclass - Add vm.SyntheticModule Refs: https://heycam.github.io/webidl/#synthetic-module-records PR-URL: https://github.com/nodejs/node/pull/29864 Reviewed-By: Guy Bedford <guybedford@gmail.com>
* vm: refactor SourceTextModuleGus Caplan2019-10-021-65/+10
| | | | | | | | | | | | | | | | - Removes redundant `instantiate` method - Refactors `link` to match the spec linking steps more accurately - Removes URL validation from SourceTextModule specifiers - DRYs some dynamic import logic Closes: https://github.com/nodejs/node/issues/29030 Co-Authored-By: Michaël Zasso <targos@protonmail.com> PR-URL: https://github.com/nodejs/node/pull/29776 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
* test: test error when breakOnSigint is not a boolean for evaluateRuwan Geeganage2019-05-111-0/+15
| | | | | | | | PR-URL: https://github.com/nodejs/node/pull/27503 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* test: simplify vm-module-errors testRuben Bridgewater2019-04-101-36/+13
| | | | | | | | | | Use `assert.rejects` to test error cases. This simplifies the test. PR-URL: https://github.com/nodejs/node/pull/27123 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: James M Snell <jasnell@gmail.com>
* test: remove unused catch bindingscjihrig2018-11-061-2/+2
| | | | | | PR-URL: https://github.com/nodejs/node/pull/24079 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Wyatt Preul <wpreul@gmail.com>
* test: augment tests for SourceTextModuleAndrew Eisenberg2018-10-151-1/+13
| | | | | | | | | | | | | | | Adds tests for a few error conditions. Also, adds tests to make sure the dynamically generated url is correct. PR-URL: https://github.com/nodejs/node/pull/23573 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> PR-URL: https://github.com/nodejs/node/pull/23572 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* test: adding test coverage for SourceTextModule.evaluateKayla Altepeter2018-10-121-0/+9
| | | | | | | | | | This checks that invalid option throws an error. PR-URL: https://github.com/nodejs/node/pull/23595 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
* vm: rename vm.Module to vm.SourceTextModuleGus Caplan2018-07-311-22/+22
| | | | | | | | | | | | | | | | | | | | | At the last TC39 meeting, a new type of Module Records backed by JavaScript source called Dynamic Module Records was discussed, and it is now at Stage 1. Regardless of whether that proposal makes it all the way into the spec, SourceTextModule is indeed a more descriptive and accurate name for what this class represents. PR-URL: https://github.com/nodejs/node/pull/22007 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
* test: make crashOnUnhandleRejection opt-outMichaël Zasso2018-07-191-1/+0
| | | | | | | | | | | | | | | | | | This commit removes `common.crashOnUnhandledRejection()` and adds `common.disableCrashOnUnhandledRejection()`. To reduce the risk of mistakes and make writing tests that involve promises simpler, always install the unhandledRejection hook in tests and provide a way to disable it for the rare cases where it's needed. PR-URL: https://github.com/nodejs/node/pull/21849 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* test: add url type check in Module optionsJiaHerr Tee2018-02-091-1/+1
| | | | | | | | | | | | | The code coverage in `root/internal/vm/Module.js` lacked test coverage for the url options paramter. The test adds a check to ensure error is thrown. PR-URL: https://github.com/nodejs/node/pull/18664 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* vm: flip Module#link's signatureGus Caplan2018-02-031-1/+1
| | | | | | | | | | | | | The specifier parameter is deemed to be more essential than referencingModule. Flipping the parameter order allows developers to write simple linker functions that only take in a specifier. PR-URL: https://github.com/nodejs/node/pull/18471 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
* vm: add modulesGus Caplan2018-01-301-0/+264
Adds vm.Module, which wraps around ModuleWrap to provide an interface for developers to work with modules in a more reflective manner. Co-authored-by: Timothy Gu <timothygu99@gmail.com> PR-URL: https://github.com/nodejs/node/pull/17560 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>