Create object using object manager in magento 2
Please try using the object manager to test it even though is not recommended. Dependency injection must be used.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$configLoader = $objectManager->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class);
$objectManager->configure($configLoader->load('frontend'));