Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
another e2e test
  • Loading branch information
bahmutov committed Feb 5, 2020
commit 6a5f70e455670902a970b05ddd6e3195e6ed3b07
30 changes: 30 additions & 0 deletions __snapshots__/e2e_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,33 @@ context('math.js', function () {
},{"./math":1}]},{},[2]);

`

exports['sub import'] = `
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";

var sub = function sub(a, b) {
return a - b;
};

module.exports = {
sub: sub
};

},{}],2:[function(require,module,exports){
"use strict";

var _sub = require("./sub");

context('sub.js', function () {
it('imports function', function () {
expect(_sub.sub, 'sub').to.be.a('function');
});
it('can subtract numbers', function () {
expect((0, _sub.sub)(1, 2)).to.eq(-1);
});
});

},{"./sub":1}]},{},[2]);

`
9 changes: 8 additions & 1 deletion test/e2e/e2e_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ describe('browserify preprocessor - e2e', function () {

describe('imports and exports', () => {
it('handles imports and exports', () => {

return bundle('math_spec.js').then((output) => {
// check that bundled tests work
eval(output)
snapshot('math default exports', output)
})
})

it('handles module.exports and import', () => {
return bundle('sub_spec.js').then((output) => {
// check that bundled tests work
eval(output)
snapshot('sub import', output)
})
})
})
3 changes: 3 additions & 0 deletions test/fixtures/sub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const sub = (a, b) => a - b

module.exports = {sub}
10 changes: 10 additions & 0 deletions test/fixtures/sub_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { sub } from './sub'

context('sub.js', function () {
it('imports function', () => {
expect(sub, 'sub').to.be.a('function')
})
it('can subtract numbers', function () {
expect(sub(1, 2)).to.eq(-1)
})
})