diff --git a/index.js b/index.js index c05e3587..e5bc5af2 100644 --- a/index.js +++ b/index.js @@ -1157,6 +1157,10 @@ class Encore { return this; } + isRuntimeEnvironmentConfigured() { + return runtimeConfig !== null; + } + /** * Clear the runtime environment. * @@ -1213,6 +1217,7 @@ const EncoreProxy = new Proxy(new Encore(), { const safeMethods = [ 'configureRuntimeEnvironment', 'clearRuntimeEnvironment', + 'isRuntimeEnvironmentConfigured', ]; if (!webpackConfig && (safeMethods.indexOf(prop) === -1)) { diff --git a/test/index.js b/test/index.js index 0516c64f..abc649de 100644 --- a/test/index.js +++ b/test/index.js @@ -414,6 +414,22 @@ describe('Public API', () => { }); + describe('isRuntimeEnvironmentConfigured', () => { + + it('should return true if the runtime environment has been configured', () => { + const returnedValue = api.isRuntimeEnvironmentConfigured(); + expect(returnedValue).to.be.true; + }); + + it('should return false if the runtime environment has not been configured', () => { + api.clearRuntimeEnvironment(); + + const returnedValue = api.isRuntimeEnvironmentConfigured(); + expect(returnedValue).to.be.false; + }); + + }); + describe('Runtime environment proxy', () => { beforeEach(() => { api.clearRuntimeEnvironment();