-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from embroider-build/mjs-support
Enable both CJS and ESM builds
- Loading branch information
Showing
21 changed files
with
768 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
/*.d.ts | ||
/*.js | ||
/*.js.map | ||
/build/ | ||
/dist/ | ||
/*.log | ||
/typedoc | ||
!.eslintrc.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { Project } from 'fixturify-project'; | ||
import { Scenarios } from './index.js'; | ||
import Qunit from 'qunit'; | ||
import child_process from 'child_process'; | ||
|
||
function hello1(project) { | ||
project.linkDependency('hello', { | ||
baseDir: './fixtures', | ||
resolveName: 'hello1', | ||
}); | ||
} | ||
|
||
function hello2(project) { | ||
project.linkDependency('hello', { | ||
baseDir: './fixtures', | ||
resolveName: 'hello', | ||
}); | ||
} | ||
|
||
const scenarios = Scenarios.fromDir('./fixtures/app').expand({ | ||
hello1, | ||
hello2, | ||
}); | ||
|
||
scenarios.forEachScenario((scenario) => { | ||
Qunit.module(scenario.name, (hooks) => { | ||
hooks.before(async function ({ app }) { | ||
this.app = await scenario.prepare(); | ||
}); | ||
|
||
Qunit.test( | ||
'yarn test', | ||
async function (assert) { | ||
const result = await this.app.execute('yarn --silent test'); | ||
assert.equal( | ||
result.stdout, | ||
`TAP version 13 | ||
ok 1 project > createHello | ||
1..1 | ||
# pass 1 | ||
# skip 0 | ||
# todo 0 | ||
# fail 0 | ||
` | ||
); | ||
} | ||
); | ||
|
||
Qunit.test( | ||
'yarn bin inside app', | ||
async function (assert) { | ||
let result = await this.app.execute('yarn --silent bin'); | ||
const yarnBin = result.stdout.trimRight(); | ||
assert.ok(yarnBin.startsWith(this.app.dir)); | ||
result = await this.app.execute('yarn --silent exec which qunit'); | ||
assert.ok(result.stdout.startsWith(yarnBin)); | ||
} | ||
); | ||
|
||
Qunit.test( | ||
'check scenario', | ||
async function (assert) { | ||
let result = await this.app.execute( | ||
`node -p 'require("./index").polyfilled'` | ||
); | ||
assert.equal( | ||
result.stdout.trim(), | ||
('hello1' === scenario.name).toString() | ||
); | ||
} | ||
); | ||
}); | ||
}); | ||
|
||
Qunit.module('cli', () => { | ||
Qunit.test('list', (assert) => { | ||
assert.deepEqual( | ||
child_process | ||
.execFileSync( | ||
process.execPath, | ||
['cli.js', 'list', '--files', 'test-modules.mjs', '--matrix'], | ||
{ encoding: 'utf8' } | ||
) | ||
.trimRight() | ||
.split('\n'), | ||
['hello1', 'hello2'] | ||
); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"use strict"; | ||
|
||
const { Scenarios } = require('scenario-tester'); | ||
const qunit = require("qunit"); | ||
const child_process = require("child_process"); | ||
const execa = require('execa'); | ||
|
||
function hello1(project) { | ||
project.linkDependency('hello', { | ||
baseDir: './tests/fixtures', | ||
resolveName: 'hello1', | ||
}); | ||
} | ||
function hello2(project) { | ||
project.linkDependency('hello', { | ||
baseDir: './tests/fixtures', | ||
resolveName: 'hello', | ||
}); | ||
} | ||
const scenarios = Scenarios.fromDir('./tests/fixtures/app').expand({ | ||
hello1, | ||
hello2, | ||
}); | ||
scenarios.forEachScenario((scenario) => { | ||
qunit.module(scenario.name, (hooks) => { | ||
hooks.before(async function () { | ||
this.app = await scenario.prepare(); | ||
}); | ||
qunit.test('yarn test', async function (assert) { | ||
const result = await this.app.execute('yarn --silent test'); | ||
assert.equal(result.stdout, `TAP version 13 | ||
ok 1 project > createHello | ||
1..1 | ||
# pass 1 | ||
# skip 0 | ||
# todo 0 | ||
# fail 0 | ||
`); | ||
}); | ||
qunit.test('yarn bin inside app', async function (assert) { | ||
let result = await this.app.execute('yarn --silent bin'); | ||
const yarnBin = result.stdout.trimRight(); | ||
assert.ok(yarnBin.startsWith(this.app.dir)); | ||
result = await this.app.execute('yarn --silent exec which qunit'); | ||
assert.ok(result.stdout.startsWith(yarnBin)); | ||
}); | ||
qunit.test('check scenario', async function (assert) { | ||
let result = await this.app.execute(`node -p 'require("./index").polyfilled'`); | ||
assert.equal(result.stdout.trim(), ('hello1' === scenario.name).toString()); | ||
}); | ||
}); | ||
}); | ||
qunit.module('cli', () => { | ||
qunit.test('list', async (assert) => { | ||
const result = await execa('node', ['./dist/cli.js', 'list', '--files', 'tests/test.cjs', '--matrix']) | ||
|
||
const { stdout } = result; | ||
assert.deepEqual( | ||
stdout.split('\n'), | ||
['hello1', 'hello2'] | ||
); | ||
}); | ||
}); | ||
//# sourceMappingURL=test.js.map |
Oops, something went wrong.