Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed May 3, 2024
1 parent 56ad8fa commit e10c618
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,7 @@ const mtscPath = join(__dirname, '../bin/mwtsc.js');
describe('/test/index.js', () => {
it('should throw error when no --run parameter', async () => {
await new Promise(resolve => {
process.stderr.on('data', data => {
console.log(data.toString());
resolve();
});

process.stdout.on('data', data => {
console.log(data.toString());
resolve();
});

const cp = execa('node', [mtscPath], []);
cp.stdout.pipe(process.stdout);
cp.stderr.pipe(process.stderr);
const cp = execa('node', [mtscPath], {});

cp.on('exit', code => {
console.log('exit', code);
Expand All @@ -35,22 +23,10 @@ describe('/test/index.js', () => {

it('should compile ts file and run custom js', async () => {
await new Promise((resolve, reject) => {
process.stderr.on('data', data => {
console.log(data.toString());
resolve();
});

process.stdout.on('data', data => {
console.log(data.toString());
resolve();
});

const runPath = join(__dirname, 'fixtures/base');
const cp = execa('node', [mtscPath, '--run', './run.js'], {
cwd: runPath,
});
cp.stdout.pipe(process.stdout);
cp.stderr.pipe(process.stderr);

cp.on('exit', code => {
try {
Expand Down Expand Up @@ -100,7 +76,6 @@ describe('/test/index.js', () => {

const cp = execa('node', [mtscPath, '--watch', '--run', './run.js'], {
cwd: runPath,
// stdio: 'ignore',
});

// add a new file
Expand Down Expand Up @@ -147,7 +122,6 @@ describe('/test/index.js', () => {

const cp = execa('node', [mtscPath, '--watch', '--run', './run.js'], {
cwd: runPath,
// stdio: 'ignore',
});

// change file
Expand Down

0 comments on commit e10c618

Please sign in to comment.