Skip to content

Commit

Permalink
Adds a test
Browse files Browse the repository at this point in the history
  • Loading branch information
Maël Nison committed Apr 26, 2018
1 parent 19b9613 commit 8f453f6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/pkg-tests/pkg-tests-specs/sources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

exports.basic = require('./basic');
exports.dragon = require('./dragon');
exports.script = require('./script');
20 changes: 20 additions & 0 deletions packages/pkg-tests/pkg-tests-specs/sources/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* @flow */

import type {PackageDriver} from 'pkg-tests-core';

const {fs: {makeFakeBinary}} = require(`pkg-tests-core`);

module.exports = (makeTemporaryEnv: PackageDriver) => {
describe(`Scripts tests`, () => {
test(
`it should run scripts using the same Node than the one used by Yarn`,
makeTemporaryEnv({scripts: {myScript: `node --version`}}, async ({path, run, source}) => {
await makeFakeBinary(`${path}/bin/node`);

await expect(run(`run`, `myScript`)).resolves.toMatchObject({
stdout: `${process.version}\n`,
});
}),
);
});
};
3 changes: 2 additions & 1 deletion packages/pkg-tests/yarn.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {
exec: {execFile},
} = require(`pkg-tests-core`);

const {basic: basicSpecs, dragon: dragonSpecs} = require(`pkg-tests-specs`);
const {basic: basicSpecs, dragon: dragonSpecs, script: scriptSpecs} = require(`pkg-tests-specs`);

const pkgDriver = generatePkgDriver({
runDriver: (path, args, {registryUrl}) => {
Expand All @@ -24,3 +24,4 @@ beforeEach(async () => {

basicSpecs(pkgDriver);
dragonSpecs(pkgDriver);
scriptSpecs(pkgDriver);

0 comments on commit 8f453f6

Please sign in to comment.