mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1473295 - add enviroment for unit tests, r=jdescottes,ladybenko
Differential Revision: https://phabricator.services.mozilla.com/D32959 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
bd1d104ad9
commit
ae788a0773
@ -6,5 +6,5 @@
|
||||
|
||||
module.exports = {
|
||||
// Extend from the shared list of defined globals for mochitests.
|
||||
"extends": "../../../.eslintrc.mochitests.js"
|
||||
"extends": "../../../.eslintrc.mochitests.js",
|
||||
};
|
||||
|
8
devtools/client/application/test/babel.config.js
Normal file
8
devtools/client/application/test/babel.config.js
Normal file
@ -0,0 +1,8 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
"plugins": ["@babel/plugin-proposal-async-generator-functions"],
|
||||
};
|
@ -0,0 +1,69 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Dummy test shallow renders a component 1`] = `
|
||||
<article
|
||||
className="worker-list-empty"
|
||||
>
|
||||
<Localized
|
||||
a={
|
||||
<a
|
||||
className="external-link"
|
||||
onClick={[Function]}
|
||||
/>
|
||||
}
|
||||
id="serviceworker-empty-intro"
|
||||
>
|
||||
<h1
|
||||
className="worker-list-empty__title"
|
||||
/>
|
||||
</Localized>
|
||||
<Localized
|
||||
id="serviceworker-empty-suggestions"
|
||||
>
|
||||
<p />
|
||||
</Localized>
|
||||
<ul
|
||||
className="worker-list-empty__tips"
|
||||
>
|
||||
<Localized
|
||||
a={
|
||||
<a
|
||||
className="link"
|
||||
onClick={[Function]}
|
||||
/>
|
||||
}
|
||||
id="serviceworker-empty-suggestions-console"
|
||||
>
|
||||
<li
|
||||
className="worker-list-empty__tips__item"
|
||||
/>
|
||||
</Localized>
|
||||
<Localized
|
||||
a={
|
||||
<a
|
||||
className="link"
|
||||
onClick={[Function]}
|
||||
/>
|
||||
}
|
||||
id="serviceworker-empty-suggestions-debugger"
|
||||
>
|
||||
<li
|
||||
className="worker-list-empty__tips__item"
|
||||
/>
|
||||
</Localized>
|
||||
<Localized
|
||||
a={
|
||||
<a
|
||||
className="link js-trusted-link"
|
||||
onClick={[Function]}
|
||||
/>
|
||||
}
|
||||
id="serviceworker-empty-suggestions-aboutdebugging"
|
||||
>
|
||||
<li
|
||||
className="worker-list-empty__tips__item"
|
||||
/>
|
||||
</Localized>
|
||||
</ul>
|
||||
</article>
|
||||
`;
|
22
devtools/client/application/test/components/dummy.test.js
Normal file
22
devtools/client/application/test/components/dummy.test.js
Normal file
@ -0,0 +1,22 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* eslint-env jest */
|
||||
const { shallow } = require("enzyme");
|
||||
const React = require("react");
|
||||
|
||||
const WorkerListEmpty = require("devtools/client/application/src/components/WorkerListEmpty");
|
||||
const WorkerListEmptyComp = React.createFactory(WorkerListEmpty);
|
||||
|
||||
/**
|
||||
* Dummy test to check if setup is working + we render one component
|
||||
*/
|
||||
|
||||
describe("Dummy test", () => {
|
||||
it("shallow renders a component", () => {
|
||||
const wrapper = shallow(WorkerListEmptyComp({}));
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
});
|
11
devtools/client/application/test/fixtures/Chrome.js
vendored
Normal file
11
devtools/client/application/test/fixtures/Chrome.js
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
Cc: {},
|
||||
Ci: {},
|
||||
Cu: {},
|
||||
};
|
11
devtools/client/application/test/fixtures/PluralForm.js
vendored
Normal file
11
devtools/client/application/test/fixtures/PluralForm.js
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports.PluralForm = {
|
||||
get(num, str) {
|
||||
return str;
|
||||
},
|
||||
};
|
9
devtools/client/application/test/fixtures/Services.js
vendored
Normal file
9
devtools/client/application/test/fixtures/Services.js
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
appinfo: "",
|
||||
};
|
23
devtools/client/application/test/fixtures/l10n.js
vendored
Normal file
23
devtools/client/application/test/fixtures/l10n.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
"use strict";
|
||||
|
||||
// @TODO Load the actual strings from instead.
|
||||
class L10N {
|
||||
getStr(str) {
|
||||
switch (str) {
|
||||
default:
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
getFormatStr(str) {
|
||||
return this.getStr(str);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
L10N: new L10N(),
|
||||
};
|
7
devtools/client/application/test/fixtures/stub.js
vendored
Normal file
7
devtools/client/application/test/fixtures/stub.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = {};
|
26
devtools/client/application/test/jest.config.js
Normal file
26
devtools/client/application/test/jest.config.js
Normal file
@ -0,0 +1,26 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* global __dirname */
|
||||
|
||||
module.exports = {
|
||||
verbose: true,
|
||||
moduleNameMapper: {
|
||||
// Custom name mappers for modules that require m-c specific API.
|
||||
"^../utils/l10n": `${__dirname}/fixtures/l10n`,
|
||||
"^devtools/client/shared/link": `${__dirname}/fixtures/stub`,
|
||||
"^devtools/shared/plural-form": `${__dirname}/fixtures/plural-form`,
|
||||
"^chrome": `${__dirname}/fixtures/Chrome`,
|
||||
"^Services": `${__dirname}/fixtures/Services`,
|
||||
// Map all require("devtools/...") to the real devtools root.
|
||||
"^devtools\\/(.*)": `${__dirname}/../../../$1`,
|
||||
},
|
||||
setupFiles: [
|
||||
"<rootDir>setup.js",
|
||||
],
|
||||
snapshotSerializers: [
|
||||
"enzyme-to-json/serializer",
|
||||
],
|
||||
};
|
22
devtools/client/application/test/package.json
Normal file
22
devtools/client/application/test/package.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "application-panel-tests",
|
||||
"license": "MPL-2.0",
|
||||
"version": "0.0.1",
|
||||
"engines": {
|
||||
"node": ">=8.9.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"test-ci": "jest --json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-proposal-async-generator-functions": "^7.2.0",
|
||||
"enzyme": "^3.9.0",
|
||||
"enzyme-adapter-react-16": "^1.13.2",
|
||||
"enzyme-to-json": "^3.3.5",
|
||||
"jest": "^24.6",
|
||||
"react": "16.4.1",
|
||||
"react-dom": "16",
|
||||
"react-test-renderer": "16.4.1"
|
||||
}
|
||||
}
|
43
devtools/client/application/test/setup.js
Normal file
43
devtools/client/application/test/setup.js
Normal file
@ -0,0 +1,43 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* global global */
|
||||
|
||||
// Configure enzyme with React 16 adapter.
|
||||
const Enzyme = require("enzyme");
|
||||
const Adapter = require("enzyme-adapter-react-16");
|
||||
Enzyme.configure({ adapter: new Adapter() });
|
||||
|
||||
global.loader = {
|
||||
lazyGetter: (context, name, fn) => {
|
||||
const module = fn();
|
||||
global[name] = module;
|
||||
},
|
||||
lazyRequireGetter: (obj, property, module, destructure) => {
|
||||
Object.defineProperty(obj, property, {
|
||||
get: () => {
|
||||
// Redefine this accessor property as a data property.
|
||||
// Delete it first, to rule out "too much recursion" in case obj is
|
||||
// a proxy whose defineProperty handler might unwittingly trigger this
|
||||
// getter again.
|
||||
delete obj[property];
|
||||
const value = destructure
|
||||
? require(module)[property]
|
||||
: require(module || property);
|
||||
Object.defineProperty(obj, property, {
|
||||
value,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
});
|
||||
return value;
|
||||
},
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
});
|
||||
},
|
||||
lazyImporter: () => {},
|
||||
};
|
4113
devtools/client/application/test/yarn.lock
Normal file
4113
devtools/client/application/test/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
browser/components/translation/cld2/
|
||||
devtools/client/aboutdebugging-new/test/jest/node_modules/
|
||||
devtools/client/application/test/node_modules/
|
||||
devtools/client/debugger/node_modules/
|
||||
devtools/client/shared/build/babel.js
|
||||
devtools/client/shared/sourceeditor/codemirror/
|
||||
|
Loading…
Reference in New Issue
Block a user