add test for dev

This commit is contained in:
wuls 2023-05-05 10:33:57 +08:00
parent 283cd3eb26
commit 49b39a5c52

View file

@ -3,22 +3,40 @@ import * as cheerio from 'cheerio';
import { loadFixture, isWindows } from './test-utils.js';
describe('minification html', () => {
let fixture;
const regex = /[\r\n]+/gm;
before(async () => {
fixture = await loadFixture({ root: './fixtures/minification-html/' });
await fixture.build();
});
describe('Build', () => {
describe('in the dev', () => {
let fixture;
let devServer;
const regex = /[\r\n]+/gm;
before(async () => {
fixture = await loadFixture({
root: './fixtures/minification-html/',
});
devServer = await fixture.startDevServer();
});
after(async () => {
devServer.stop();
});
it('Verify that the HTML code is compressed in the dev', async () => {
let res = await fixture.fetch(`/`);
expect(res.status).to.equal(200);
const html = await res.text();
expect(regex.test(html.slice(-100))).to.equal(false);
});
})
describe('build', () => {
let fixture;
const regex = /[\r\n]+/gm;
before(async () => {
fixture = await loadFixture({ root: './fixtures/minification-html/' });
await fixture.build();
});
it('validating the html is or not is minification ', async () => {
it('Verify that the HTML code is compressed in the pro', async () => {
const html = await fixture.readFile('/index.html');
expect(regex.test(html.slice(20))).to.equal(false);
});
});
})
});