Skip to content

Commit

Permalink
📦 Update dependency sinon to v10 (#33418)
Browse files Browse the repository at this point in the history
* 📦 Update dependency sinon to v10

* Bundle and transform sinon, chai, and sinon-chai

Co-authored-by: Justin Ridgewell <jridgewell@google.com>
  • Loading branch information
renovate-bot and jridgewell authored Apr 27, 2021
1 parent 2c33f7a commit 6718ef9
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 33 deletions.
12 changes: 9 additions & 3 deletions build-system/common/esbuild-babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

const babel = require('@babel/core');
const path = require('path');
const {debug} = require('../compile/debug-compilation-lifecycle');
const {TransformCache, batchedRead, md5} = require('./transform-cache');

/**
Expand Down Expand Up @@ -43,17 +44,22 @@ function getEsbuildBabelPlugin(
transformCache = new TransformCache('.babel-cache', '.js');
}

async function transformContents(contents, hash, babelOptions) {
async function transformContents(filename, contents, hash, babelOptions) {
if (enableCache) {
const cached = transformCache.get(hash);
if (cached) {
return cached;
}
}

debug('pre-babel', filename, contents);
const promise = babel
.transformAsync(contents, babelOptions)
.then((result) => result.code);
.then((result) => {
const {code, map} = result;
debug('post-babel', filename, code, map);
return code;
});

if (enableCache) {
transformCache.set(hash, promise);
Expand All @@ -77,7 +83,7 @@ function getEsbuildBabelPlugin(
build.onLoad({filter: /\.[cm]?js$/, namespace: ''}, async (file) => {
const filename = file.path;
const {contents, hash} = await batchedRead(filename, optionsHash);
const transformed = await transformContents(contents, hash, {
const transformed = await transformContents(filename, contents, hash, {
...babelOptions,
filename,
filenameRelative: path.basename(filename),
Expand Down
6 changes: 2 additions & 4 deletions build-system/compile/debug-compilation-lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const pad = (value, length) =>

const LIFECYCLES = {
'pre-babel': 'pre-babel',
'post-babel': 'post-babel',
'pre-closure': 'pre-closure',
'closured-pre-babel': 'closured-pre-babel',
'closured-pre-terser': 'closured-pre-terser',
Expand Down Expand Up @@ -62,10 +63,7 @@ function debug(lifecycle, fullpath, content, sourcemap) {
}
fs.appendFileSync(
logFile,
`${pad(lifecycle, 20)}: ${pad(
path.basename(fullpath),
30
)} ${contentsPath}\n`
`${pad(lifecycle, 20)}: ${pad(fullpath, 100)} ${contentsPath}\n`
);
}
}
Expand Down
4 changes: 1 addition & 3 deletions build-system/test-configs/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (argv.debug) {
* @param {!Object} config
*/
module.exports = {
frameworks: ['fixture', 'mocha', 'sinon-chai', 'chai', 'source-map-support'],
frameworks: ['fixture', 'mocha', 'source-map-support'],

preprocessors: {}, // Dynamically populated based on tests being run.

Expand Down Expand Up @@ -154,7 +154,6 @@ module.exports = {

plugins: [
'@chiragrupani/karma-chromium-edge-launcher',
'karma-chai',
'karma-chrome-launcher',
'karma-esbuild',
'karma-firefox-launcher',
Expand All @@ -166,7 +165,6 @@ module.exports = {
'karma-mocha',
'karma-mocha-reporter',
'karma-safarinative-launcher',
'karma-sinon-chai',
'karma-source-map-support',
'karma-spec-reporter',
'karma-super-dots-reporter',
Expand Down
26 changes: 7 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
"json5": "2.2.0",
"jsonminify": "0.4.1",
"karma": "6.3.2",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-esbuild": "2.1.3",
Expand All @@ -135,7 +134,6 @@
"karma-mocha": "2.0.1",
"karma-mocha-reporter": "2.2.5",
"karma-safarinative-launcher": "1.1.0",
"karma-sinon-chai": "2.0.2",
"karma-source-map-support": "1.4.0",
"karma-spec-reporter": "0.0.32",
"karma-structured-json-reporter": "1.0.1",
Expand Down Expand Up @@ -164,7 +162,7 @@
"react-dom": "17.0.2",
"rocambole": "0.7.0",
"semver": "7.3.5",
"sinon": "9.2.4",
"sinon": "10.0.0",
"sinon-chai": "3.6.0",
"sourcemap-codec": "1.4.8",
"stream-browserify": "3.0.0",
Expand Down
4 changes: 3 additions & 1 deletion test/_init_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
* limitations under the License.
*/

// This must load before all other tests.
// These must load before all other tests.
import '../src/polyfills';
import './_setup_test_framework';

import * as coreError from '../src/core/error';
import * as describes from '../testing/describes';
import {Services} from '../src/services';
Expand Down
28 changes: 28 additions & 0 deletions test/_setup_test_framework.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright 2021 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* eslint-disable */
import chai from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';

chai.use(sinonChai);
window.chai = chai;
window.should = chai.should();
window.expect = chai.expect;
window.assert = chai.assert;
window.sinon = sinon;

0 comments on commit 6718ef9

Please sign in to comment.