|
4 | 4 |
|
5 | 5 | const common = require('../common'); |
6 | 6 | const assert = require('assert'); |
7 | | -const { Module, SourceTextModule, SyntheticModule, createContext } = require('vm'); |
| 7 | +const { |
| 8 | + Module, |
| 9 | + SourceTextModule, |
| 10 | + SyntheticModule, |
| 11 | + createContext |
| 12 | +} = require('vm'); |
8 | 13 | const util = require('util'); |
9 | 14 |
|
10 | 15 | (async function test1() { |
@@ -110,39 +115,35 @@ const util = require('util'); |
110 | 115 |
|
111 | 116 | // Check the impossibility of creating an abstract instance of the Module. |
112 | 117 | { |
113 | | - assert.throws( |
114 | | - () => { |
115 | | - new Module(); |
116 | | - }, |
117 | | - /^TypeError: Module is not a constructor$/ |
118 | | - ); |
119 | | - |
| 118 | + common.expectsError(() => new Module(), { |
| 119 | + message: 'Module is not a constructor', |
| 120 | + type: TypeError |
| 121 | + }); |
120 | 122 | } |
121 | 123 |
|
122 | 124 | // Check to throws invalid exportNames |
123 | 125 | { |
124 | | - assert.throws( |
125 | | - () => { |
126 | | - new SyntheticModule(undefined, () => {}, {}); |
127 | | - }, |
128 | | - ); |
| 126 | + common.expectsError(() => new SyntheticModule(undefined, () => {}, {}), { |
| 127 | + message: 'The "exportNames" argument must be an Array of strings.' + |
| 128 | + ' Received undefined', |
| 129 | + type: TypeError |
| 130 | + }); |
129 | 131 | } |
130 | 132 |
|
131 | 133 | // Check to throws invalid evaluateCallback |
132 | 134 | { |
133 | | - assert.throws( |
134 | | - () => { |
135 | | - new SyntheticModule([], undefined, {}); |
136 | | - }, |
137 | | - ); |
| 135 | + common.expectsError(() => new SyntheticModule([], undefined, {}), { |
| 136 | + message: 'The "evaluateCallback" argument must be of type function.' + |
| 137 | + ' Received undefined', |
| 138 | + type: TypeError |
| 139 | + }); |
138 | 140 | } |
139 | 141 |
|
140 | 142 | // Check to throws invalid options |
141 | 143 | { |
142 | | - assert.throws( |
143 | | - () => { |
144 | | - new SyntheticModule([], () => {}, null); |
145 | | - }, |
146 | | - ); |
| 144 | + common.expectsError(() => new SyntheticModule([], () => {}, null), { |
| 145 | + message: 'The "options" argument must be of type object.' + |
| 146 | + ' Received null', |
| 147 | + type: TypeError |
| 148 | + }); |
147 | 149 | } |
148 | | - |
|
0 commit comments