-
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.
add tests for explicit modules and commonjs
- Loading branch information
Showing
4 changed files
with
833 additions
and
1 deletion.
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
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,62 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const index_js_1 = require("./index.js"); | ||
const qunit_1 = __importDefault(require("qunit")); | ||
const child_process_1 = __importDefault(require("child_process")); | ||
function hello1(project) { | ||
project.linkDependency('hello', { | ||
baseDir: './fixtures', | ||
resolveName: 'hello1', | ||
}); | ||
} | ||
function hello2(project) { | ||
project.linkDependency('hello', { | ||
baseDir: './fixtures', | ||
resolveName: 'hello', | ||
}); | ||
} | ||
const scenarios = index_js_1.Scenarios.fromDir('./fixtures/app').expand({ | ||
hello1, | ||
hello2, | ||
}); | ||
scenarios.forEachScenario((scenario) => { | ||
qunit_1.default.module(scenario.name, (hooks) => { | ||
hooks.before(async function () { | ||
this.app = await scenario.prepare(); | ||
}); | ||
qunit_1.default.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_1.default.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_1.default.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_1.default.module('cli', () => { | ||
qunit_1.default.test('list', (assert) => { | ||
assert.deepEqual(child_process_1.default | ||
.execFileSync(process.execPath, ['cli.js', 'list', '--files', 'test.js', '--matrix'], { encoding: 'utf8' }) | ||
.trimRight() | ||
.split('\n'), ['hello1', 'hello2']); | ||
}); | ||
}); | ||
//# sourceMappingURL=test.js.map |
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'] | ||
); | ||
}); | ||
}); |
Oops, something went wrong.