Skip to content

Commit

Permalink
test: move ESM fixtures to fixtures dir
Browse files Browse the repository at this point in the history
Also consistently import the `common` module where possible.

PR-URL: #19409
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Khaidi Chu <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
  • Loading branch information
targos committed Mar 21, 2018
1 parent 9b7a691 commit fddcd62
Show file tree
Hide file tree
Showing 24 changed files with 30 additions and 40 deletions.
3 changes: 0 additions & 3 deletions test/es-module/esm-snapshot.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/es-module/test-esm-basic-imports.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Flags: --experimental-modules
import '../common';
import assert from 'assert';
import ok from './test-esm-ok.mjs';
import ok from '../fixtures/es-modules/test-esm-ok.mjs';
import okShebang from './test-esm-shebang.mjs';

assert(ok);
Expand Down
2 changes: 1 addition & 1 deletion test/es-module/test-esm-double-encoding.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import '../common';

// Assert we can import files with `%` in their pathname.

import './test-esm-double-encoding-native%2520.js';
import '../fixtures/es-modules/test-esm-double-encoding-native%2520.js';
4 changes: 2 additions & 2 deletions test/es-module/test-esm-dynamic-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const vm = require('vm');

common.crashOnUnhandledRejection();

const relativePath = './test-esm-ok.mjs';
const absolutePath = require.resolve('./test-esm-ok.mjs');
const relativePath = '../fixtures/es-modules/test-esm-ok.mjs';
const absolutePath = require.resolve('../fixtures/es-modules/test-esm-ok.mjs');
const targetURL = new URL('file:///');
targetURL.pathname = absolutePath;

Expand Down
2 changes: 1 addition & 1 deletion test/es-module/test-esm-encoded-path.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
import '../common';
import assert from 'assert';
// ./test-esm-ok.mjs
import ok from './test-%65%73%6d-ok.mjs';
import ok from '../fixtures/es-modules/test-%65%73%6d-ok.mjs';

assert(ok);
2 changes: 1 addition & 1 deletion test/es-module/test-esm-example-loader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/example-loader.mjs
/* eslint-disable node-core/required-modules */
import assert from 'assert';
import ok from './test-esm-ok.mjs';
import ok from '../fixtures/es-modules/test-esm-ok.mjs';

assert(ok);
2 changes: 1 addition & 1 deletion test/es-module/test-esm-forbidden-globals.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Flags: --experimental-modules
/* eslint-disable node-core/required-modules */
import '../common';

if (typeof arguments !== 'undefined') {
throw new Error('not an ESM');
Expand Down
7 changes: 3 additions & 4 deletions test/es-module/test-esm-json.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Flags: --experimental-modules
/* eslint-disable node-core/required-modules */
import '../common/index';
import '../common';
import assert from 'assert';
import ok from './test-esm-ok.mjs';
import json from './json.json';
import ok from '../fixtures/es-modules/test-esm-ok.mjs';
import json from '../fixtures/es-modules/json.json';

assert(ok);
assert.strictEqual(json.val, 42);
2 changes: 1 addition & 1 deletion test/es-module/test-esm-loader-dependency.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/loader-with-dep.mjs
/* eslint-disable node-core/required-modules */
import './test-esm-ok.mjs';
import '../fixtures/es-modules/test-esm-ok.mjs';

// We just test that this module doesn't fail loading
2 changes: 1 addition & 1 deletion test/es-module/test-esm-main-lookup.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Flags: --experimental-modules
/* eslint-disable node-core/required-modules */
import '../common';
import assert from 'assert';
import main from '../fixtures/es-modules/pjson-main';

Expand Down
5 changes: 2 additions & 3 deletions test/es-module/test-esm-named-exports.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/builtin-named-exports-loader.mjs
/* eslint-disable node-core/required-modules */
import '../common/index';
import '../common';
import { readFile } from 'fs';
import assert from 'assert';
import ok from './test-esm-ok.mjs';
import ok from '../fixtures/es-modules/test-esm-ok.mjs';

assert(ok);
assert(readFile);
4 changes: 1 addition & 3 deletions test/es-module/test-esm-namespace.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Flags: --experimental-modules
/* eslint-disable node-core/required-modules */

import '../common/index';
import '../common';
import * as fs from 'fs';
import assert from 'assert';

Expand Down
5 changes: 0 additions & 5 deletions test/es-module/test-esm-ok.mjs

This file was deleted.

1 change: 0 additions & 1 deletion test/es-module/test-esm-preserve-symlinks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Flags: --experimental-modules
'use strict';

const common = require('../common');
Expand Down
2 changes: 1 addition & 1 deletion test/es-module/test-esm-resolve-hook.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable node-core/required-modules */
import { namedExport } from '../fixtures/es-module-loaders/js-as-esm.js';
import assert from 'assert';
import ok from './test-esm-ok.mjs';
import ok from '../fixtures/es-modules/test-esm-ok.mjs';

assert(ok);
assert(namedExport);
4 changes: 2 additions & 2 deletions test/es-module/test-esm-shared-loader-dep.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/loader-shared-dep.mjs
/* eslint-disable node-core/required-modules */
import '../common';
import assert from 'assert';
import './test-esm-ok.mjs';
import '../fixtures/es-modules/test-esm-ok.mjs';
import dep from '../fixtures/es-module-loaders/loader-dep.js';

assert.strictEqual(dep.format, 'esm');
2 changes: 1 addition & 1 deletion test/es-module/test-esm-shebang.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! }]) // isn't js
// Flags: --experimental-modules
/* eslint-disable node-core/required-modules */
import '../common';

const isJs = true;
export default isJs;
7 changes: 3 additions & 4 deletions test/es-module/test-esm-snapshot.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Flags: --experimental-modules
/* eslint-disable node-core/required-modules */
import '../common/index';
import './esm-snapshot-mutator';
import one from './esm-snapshot';
import '../common';
import '../fixtures/es-modules/esm-snapshot-mutator';
import one from '../fixtures/es-modules/esm-snapshot';
import assert from 'assert';

assert.strictEqual(one, 1);
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node-core/required-modules */
'use strict';
const shouldSnapshotFilePath = require.resolve('./esm-snapshot.js');
require('./esm-snapshot.js');
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/es-modules/esm-snapshot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict';
module.exports = 1;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
require('../common');

// Trivial test to assert we can load files with `%` in their pathname.
// Imported by `test-esm-double-encoding.mjs`.
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/es-modules/test-esm-ok.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const isJs = true;
export default isJs;
6 changes: 4 additions & 2 deletions test/parallel/test-module-main-extension-lookup.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'use strict';
require('../common');
const fixtures = require('../common/fixtures');
const { execFileSync } = require('child_process');

const node = process.argv[0];

execFileSync(node, ['--experimental-modules', 'test/es-module/test-esm-ok']);
execFileSync(node, ['--experimental-modules',
'test/fixtures/es-modules/noext']);
fixtures.path('es-modules', 'test-esm-ok')]);
execFileSync(node, ['--experimental-modules',
fixtures.path('es-modules', 'noext')]);

0 comments on commit fddcd62

Please sign in to comment.