Skip to content

Commit

Permalink
convert tests to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeybinns committed Aug 28, 2024
1 parent 4835a90 commit ee076ce
Show file tree
Hide file tree
Showing 14 changed files with 114 additions and 99 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
"test:performance:debug": "wp-scripts test-playwright --config test/performance/playwright.config.ts --debug",
"test:php": "npm-run-all lint:php test:unit:php",
"test:php:watch": "wp-env run --env-cwd='wp-content/plugins/gutenberg' tests-cli composer run-script test:watch",
"test:unit": "wp-scripts test-unit-js --config test/unit/jest.config.js",
"test:unit": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" wp-scripts test-unit-js --config test/unit/jest.config.js",
"test:unit:date": "bash ./bin/unit-test-date.sh",
"test:unit:debug": "wp-scripts --inspect-brk test-unit-js --runInBand --no-cache --verbose --config test/unit/jest.config.js ",
"test:unit:profile": "wp-scripts --cpu-prof test-unit-js --runInBand --no-cache --verbose --config test/unit/jest.config.js ",
Expand Down
17 changes: 9 additions & 8 deletions packages/stylelint-config/test/commenting.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* External dependencies
*/
const fs = require( 'fs' ),
stylelint = require( 'stylelint' );
import fs from 'node:fs';
import stylelint from 'stylelint';

/**
* Internal dependencies
*/
const config = require( '../stylistic' ),
validCss = fs.readFileSync(
import config from '../stylistic';

const validCss = fs.readFileSync(
'./packages/stylelint-config/test/commenting-valid.css',
'utf-8'
),
Expand All @@ -23,8 +24,8 @@ const config = require( '../stylistic' ),
describe( 'flags no warnings with valid commenting css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: validCss,
config,
} );
Expand All @@ -44,8 +45,8 @@ describe( 'flags no warnings with valid commenting css', () => {
describe( 'flags warnings with invalid commenting css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: invalidCss,
config,
} );
Expand Down
17 changes: 9 additions & 8 deletions packages/stylelint-config/test/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* External dependencies
*/
const fs = require( 'fs' ),
stylelint = require( 'stylelint' );
import fs from 'node:fs';
import stylelint from 'stylelint';

/**
* Internal dependencies
*/
const config = require( '../stylistic' ),
validCss = fs.readFileSync(
import config from '../stylistic';

const validCss = fs.readFileSync(
'./packages/stylelint-config/test/functions-valid.css',
'utf-8'
),
Expand All @@ -23,8 +24,8 @@ const config = require( '../stylistic' ),
describe( 'flags no warnings with valid functions css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: validCss,
config,
} );
Expand All @@ -44,8 +45,8 @@ describe( 'flags no warnings with valid functions css', () => {
describe( 'flags warnings with invalid functions css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: invalidCss,
config,
} );
Expand Down
17 changes: 9 additions & 8 deletions packages/stylelint-config/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* External dependencies
*/
const fs = require( 'fs' ),
stylelint = require( 'stylelint' );
import fs from 'node:fs';
import stylelint from 'stylelint';

/**
* Internal dependencies
*/
const config = require( '../stylistic' ),
validCss = fs.readFileSync(
import config from '../stylistic';

const validCss = fs.readFileSync(
'./packages/stylelint-config/test/css-valid.css',
'utf-8'
),
Expand All @@ -23,8 +24,8 @@ const config = require( '../stylistic' ),
describe( 'flags no warnings with valid css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: validCss,
config,
} );
Expand All @@ -44,8 +45,8 @@ describe( 'flags no warnings with valid css', () => {
describe( 'flags warnings with invalid css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: invalidCss,
config,
} );
Expand Down
17 changes: 9 additions & 8 deletions packages/stylelint-config/test/media-queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* External dependencies
*/
const fs = require( 'fs' ),
stylelint = require( 'stylelint' );
import fs from 'node:fs';
import stylelint from 'stylelint';

/**
* Internal dependencies
*/
const config = require( '../stylistic' ),
validCss = fs.readFileSync(
import config from '../stylistic';

const validCss = fs.readFileSync(
'./packages/stylelint-config/test/media-queries-valid.css',
'utf-8'
),
Expand All @@ -23,8 +24,8 @@ const config = require( '../stylistic' ),
describe( 'flags no warnings with valid media queries css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: validCss,
config,
} );
Expand All @@ -44,8 +45,8 @@ describe( 'flags no warnings with valid media queries css', () => {
describe( 'flags warnings with invalid media queries css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: invalidCss,
config,
} );
Expand Down
3 changes: 3 additions & 0 deletions packages/stylelint-config/test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
17 changes: 9 additions & 8 deletions packages/stylelint-config/test/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* External dependencies
*/
const fs = require( 'fs' ),
stylelint = require( 'stylelint' );
import fs from 'node:fs';
import stylelint from 'stylelint';

/**
* Internal dependencies
*/
const config = require( '../stylistic' ),
validCss = fs.readFileSync(
import config from '../stylistic';

const validCss = fs.readFileSync(
'./packages/stylelint-config/test/properties-valid.css',
'utf-8'
),
Expand All @@ -23,8 +24,8 @@ const config = require( '../stylistic' ),
describe( 'flags no warnings with valid properties css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: validCss,
config,
} );
Expand All @@ -44,8 +45,8 @@ describe( 'flags no warnings with valid properties css', () => {
describe( 'flags warnings with invalid properties css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: invalidCss,
config,
} );
Expand Down
17 changes: 9 additions & 8 deletions packages/stylelint-config/test/scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* External dependencies
*/
const fs = require( 'fs' ),
stylelint = require( 'stylelint' );
import fs from 'node:fs';
import stylelint from 'stylelint';

/**
* Internal dependencies
*/
const config = require( '../scss-stylistic' ),
validScss = fs.readFileSync(
import config from '../scss-stylistic';

const validScss = fs.readFileSync(
'./packages/stylelint-config/test/scss-valid.scss',
'utf-8'
),
Expand All @@ -23,8 +24,8 @@ const config = require( '../scss-stylistic' ),
describe( 'flags no warnings with valid scss', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: validScss,
config,
} );
Expand All @@ -44,8 +45,8 @@ describe( 'flags no warnings with valid scss', () => {
describe( 'flags warnings with invalid scss', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: invalidScss,
config,
} );
Expand Down
17 changes: 9 additions & 8 deletions packages/stylelint-config/test/selectors-scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* External dependencies
*/
const fs = require( 'fs' ),
stylelint = require( 'stylelint' );
import fs from 'node:fs';
import stylelint from 'stylelint';

/**
* Internal dependencies
*/
const config = require( '../scss-stylistic' ),
validScss = fs.readFileSync(
import config from '../scss-stylistic';

const validScss = fs.readFileSync(
'./packages/stylelint-config/test/selectors-valid.scss',
'utf-8'
),
Expand All @@ -23,8 +24,8 @@ const config = require( '../scss-stylistic' ),
describe( 'flags no warnings with valid selectors scss', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: validScss,
config,
} );
Expand All @@ -44,8 +45,8 @@ describe( 'flags no warnings with valid selectors scss', () => {
describe( 'flags warnings with invalid selectors scss', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: invalidScss,
config,
} );
Expand Down
17 changes: 9 additions & 8 deletions packages/stylelint-config/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* External dependencies
*/
const fs = require( 'fs' ),
stylelint = require( 'stylelint' );
import fs from 'node:fs';
import stylelint from 'stylelint';

/**
* Internal dependencies
*/
const config = require( '../stylistic' ),
validCss = fs.readFileSync(
import config from '../stylistic';

const validCss = fs.readFileSync(
'./packages/stylelint-config/test/selectors-valid.css',
'utf-8'
),
Expand All @@ -23,8 +24,8 @@ const config = require( '../stylistic' ),
describe( 'flags no warnings with valid selectors css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: validCss,
config,
} );
Expand All @@ -44,8 +45,8 @@ describe( 'flags no warnings with valid selectors css', () => {
describe( 'flags warnings with invalid selectors css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: invalidCss,
config,
} );
Expand Down
17 changes: 9 additions & 8 deletions packages/stylelint-config/test/structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* External dependencies
*/
const fs = require( 'fs' ),
stylelint = require( 'stylelint' );
import fs from 'node:fs';
import stylelint from 'stylelint';

/**
* Internal dependencies
*/
const config = require( '../stylistic' ),
validCss = fs.readFileSync(
import config from '../stylistic';

const validCss = fs.readFileSync(
'./packages/stylelint-config/test/structure-valid.css',
'utf-8'
),
Expand All @@ -23,8 +24,8 @@ const config = require( '../stylistic' ),
describe( 'flags no warnings with valid structure css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: validCss,
config,
} );
Expand All @@ -44,8 +45,8 @@ describe( 'flags no warnings with valid structure css', () => {
describe( 'flags warnings with invalid structure css', () => {
let result;

beforeEach( () => {
result = stylelint.lint( {
beforeEach( async () => {
result = ( await stylelint ).lint( {
code: invalidCss,
config,
} );
Expand Down
Loading

0 comments on commit ee076ce

Please sign in to comment.