Skip to content

Commit 59dd771

Browse files
committed
Migrate test/* test files to Vitest
1 parent 6d07e3a commit 59dd771

File tree

6 files changed

+19
-26
lines changed

6 files changed

+19
-26
lines changed

test/WebpackConfig.js renamed to test/WebpackConfig.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
'use strict';
1111

12-
const expect = require('chai').expect;
12+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
1313
const WebpackConfig = require('../lib/WebpackConfig');
1414
const RuntimeConfig = require('../lib/config/RuntimeConfig');
1515
const path = require('path');

test/config-generator.js renamed to test/config-generator.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
'use strict';
1111

12-
const expect = require('chai').expect;
12+
import { describe, it, expect, beforeEach, beforeAll, afterAll } from 'vitest';
1313
const WebpackConfig = require('../lib/WebpackConfig');
1414
const RuntimeConfig = require('../lib/config/RuntimeConfig');
1515
const configGenerator = require('../lib/config-generator');
@@ -976,12 +976,12 @@ describe('The config-generator function', () => {
976976
});
977977

978978
describe('Test shouldUseSingleRuntimeChunk', () => {
979-
before(() => {
979+
beforeAll(() => {
980980
logger.reset();
981981
logger.quiet();
982982
});
983983

984-
after(() => {
984+
afterAll(() => {
985985
logger.quiet(false);
986986
});
987987

test/functional.js renamed to test/functional.test.js

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99

1010
'use strict';
1111

12-
const chai = require('chai');
12+
import { describe, it, expect, beforeAll, afterAll, chai } from 'vitest';
1313
chai.use(require('chai-fs'));
1414
chai.use(require('chai-subset'));
15-
const expect = chai.expect;
1615
const path = require('path');
1716
const testSetup = require('./helpers/setup');
1817
const fs = require('fs-extra');
@@ -73,22 +72,16 @@ function getIntegrityData(config) {
7372
return entrypointsData.integrity;
7473
}
7574

76-
describe('Functional tests using webpack', function() {
75+
describe('Functional tests using webpack', { timeout: 10000}, function() {
7776
/** @type {import('puppeteer').Browser} */
7877
let browser;
7978

80-
// being functional tests, these can take quite long
81-
this.timeout(10000);
82-
83-
before(function(done) {
84-
puppeteer.launch().then(_browser => {
85-
browser = _browser;
86-
done();
87-
});
79+
beforeAll(async () => {
80+
browser = await puppeteer.launch()
8881
});
8982

90-
after(function(done) {
91-
browser.close().then(done);
83+
afterAll(async() => {
84+
await browser.close()
9285
});
9386

9487
describe('Basic scenarios.', () => {
@@ -1168,7 +1161,7 @@ module.exports = {
11681161

11691162
it('Babel can be configured via package.json browserlist', (done) => {
11701163
const cwd = process.cwd();
1171-
after(() => {
1164+
afterAll(() => {
11721165
process.chdir(cwd);
11731166
});
11741167

@@ -1214,7 +1207,7 @@ module.exports = {
12141207

12151208
it('Babel adds polyfills correctly', (done) => {
12161209
const cwd = process.cwd();
1217-
after(() => {
1210+
afterAll(() => {
12181211
process.chdir(cwd);
12191212
});
12201213

@@ -1267,7 +1260,7 @@ module.exports = {
12671260

12681261
it('Babel does not force transforms if they are not needed', (done) => {
12691262
const cwd = process.cwd();
1270-
after(() => {
1263+
afterAll(() => {
12711264
process.chdir(cwd);
12721265
});
12731266

@@ -2048,13 +2041,13 @@ module.exports = {
20482041
});
20492042
});
20502043

2051-
it('Symfony - Stimulus standard app is built correctly', function(done) {
2044+
it('Symfony - Stimulus standard app is built correctly', async function({ skip }) {
20522045
const appDir = testSetup.createTestAppDir();
20532046

20542047
const version = packageHelper.getPackageVersion('@symfony/stimulus-bridge');
20552048
if (!semver.satisfies(version, '^3.0.0')) {
20562049
// we support the old version, but it's not tested
2057-
this.skip();
2050+
skip();
20582051

20592052
return;
20602053
}

test/index.js renamed to test/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
'use strict';
1111

12-
const expect = require('chai').expect;
12+
import { describe, it, expect, beforeEach } from 'vitest';
1313
const sinon = require('sinon');
1414
const api = require('../index');
1515
const path = require('path');

test/logger.js renamed to test/logger.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
'use strict';
1111

12-
const expect = require('chai').expect;
12+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
1313
require('../lib/context').runtimeConfig = {};
1414
const logger = require('../lib/logger');
1515

test/package-helper.js renamed to test/package-helper.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
'use strict';
1111

12-
const expect = require('chai').expect;
12+
import { describe, it, expect, afterAll } from 'vitest';
1313
const packageHelper = require('../lib/package-helper');
1414
const path = require('path');
1515
const process = require('process');
@@ -20,7 +20,7 @@ describe('package-helper', () => {
2020
const baseCwd = process.cwd();
2121

2222
describe('recommended install command is based on the existing lock files', () => {
23-
after(() => {
23+
afterAll(() => {
2424
process.chdir(baseCwd);
2525
});
2626

0 commit comments

Comments
 (0)